diff --git a/eg/python3/futures/hello-world.hy b/eg/python3/futures/hello-world.hy new file mode 100644 index 0000000..3b031bc --- /dev/null +++ b/eg/python3/futures/hello-world.hy @@ -0,0 +1,12 @@ +(import-from concurrent.futures ThreadPoolExecutor as-completed) +(import-from random randint) + +(import-from sh sleep) + +(defn task-to-do [] (sleep (randint 1 5))) + + +(with-as (ThreadPoolExecutor 10) executor + (setf jobs (list-comp (.submit executor task-to-do) (x (range 0 10)))) + (for (future (as-completed jobs)) + (.result future)))