Skip to content

Commit

Permalink
Merge pull request hotosm#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 2cd83fd + c4a4fab commit 694c1cd
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 694c1cd

Please sign in to comment.