-
-
Save gthank/ff0236e078aabb1b6dbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with ThreadPoolExecutor(max_workers=5) as executor: | |
metadata_by_future = {} | |
csv_files = args["CSV-FILE"] | |
for csv_file in csv_files: | |
try: | |
metadata = _preprocess_csv(csv_file, in_progress_dir, | |
processed_dir) | |
future = executor.submit(process_csv, uri, metadata) | |
metadata_by_future[future] = metadata | |
except Exception: | |
log.exception("unexpected exception: failed to process <%s>", | |
csv_file) | |
failure_log.error(csv_file) | |
print("OK, what?") | |
for f in as_completed(metadata_by_future): | |
metadata = metadata_by_future[f] | |
try: | |
handle_response(f.result(timeout=10), metadata) | |
except Exception: | |
log.exception("unexpected exception: failed to process <%s>", | |
csv_file) | |
_log_permanent_failure(metadata) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment