Created
January 17, 2024 02:09
-
-
Save tai2/139c7b502b717b779c7ea34b753b50dd 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
import subprocess | |
from concurrent.futures import ThreadPoolExecutor, as_completed | |
def invoke_command(): | |
subprocess.run(["sleep", "5"]) | |
print("done") | |
def main(): | |
params = list(range(3)) | |
with ThreadPoolExecutor(max_workers=5) as executor: | |
f = executor.map( | |
lambda f: invoke_command(), params, timeout=600 | |
) | |
as_completed(f) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment