Skip to content

Commit

Permalink
Merge pull request #162 from hotosm/hotfix/thread_error
Browse files Browse the repository at this point in the history
Capture and raise error from threads
  • Loading branch information
kshitijrajsharma authored Aug 29, 2023
2 parents b5f00b8 + 6c62155 commit 70d5620
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,17 @@ def download_imagery(start: list, end: list, zm_level, base_path, source="maxar"

start_x = start_x + 1 # increase the x

# Use the ThreadPoolExecutor to download the images in parallel
with concurrent.futures.ThreadPoolExecutor() as executor:
for url in download_urls:
futures = [
executor.submit(download_image, url, base_path, source_name)
for url in download_urls
]
for future in concurrent.futures.as_completed(futures):
try:
future.result()
except Exception as e:
print(f"An exception occurred in a thread: {e}")
raise e


def request_rawdata(request_params):
Expand Down

0 comments on commit 70d5620

Please sign in to comment.