Skip to content

Commit

Permalink
wait for all futures before performing cleanup (refs #157)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 12, 2023
1 parent 5aa0b3c commit b6af0ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mergin/client_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,15 @@ def download_project_is_running(job):
Returns true/false depending on whether we have some pending downloads.
It also forwards any exceptions from workers (e.g. some network errors). If an exception
is raised, it is advised to call download_project_cancel() to abort the job.
is raised, aborts the job.
"""
for future in job.futures:
if future.done() and future.exception() is not None:
# wait for any runinnig futures and cancel any pending futures before performing cleanup, as this may cause
# issues while performing cleanup, see https://github.com/MerginMaps/mergin-py-client/issues/157
job.is_cancelled = True
job.executor.shutdown(wait=True, cancel_futures=True)

_cleanup_failed_download(job.directory, job.mp)
raise future.exception()
if future.running():
Expand Down

0 comments on commit b6af0ca

Please sign in to comment.