Created
October 24, 2023 19:25
-
-
Save Whoaa512/09fe5e44e5f02b968d3e5febec3ca913 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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