Skip to content

Instantly share code, notes, and snippets.

@tai2
Created January 17, 2024 02:09
Show Gist options
  • Save tai2/139c7b502b717b779c7ea34b753b50dd to your computer and use it in GitHub Desktop.
Save tai2/139c7b502b717b779c7ea34b753b50dd to your computer and use it in GitHub Desktop.
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