Skip to content

Instantly share code, notes, and snippets.

@Whoaa512
Created October 24, 2023 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Whoaa512/09fe5e44e5f02b968d3e5febec3ca913 to your computer and use it in GitHub Desktop.
Save Whoaa512/09fe5e44e5f02b968d3e5febec3ca913 to your computer and use it in GitHub Desktop.
from concurrent.futures import ThreadPoolExecutor, as_completed
def do_things(i, dry_run):
print(i, dry_run)
return i * 2, i * 3
def main():
build_ids = [1, 2, 3, 4, 5, 6, 7, 8, 9]
dry_run = True
deleted_count = 0
would_delete_count = 0
with ThreadPoolExecutor() as executor:
futures = {
executor.submit(
do_things,
build_id,
dry_run,
): build_id
for build_id in build_ids
}
for future in as_completed(futures):
deleted, would_delete = future.result()
would_delete_count += would_delete
deleted_count += deleted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment