summaryrefslogtreecommitdiff
path: root/t/random_wait.py
diff options
context:
space:
mode:
Diffstat (limited to 't/random_wait.py')
-rw-r--r--t/random_wait.py22
1 files changed, 0 insertions, 22 deletions
diff --git a/t/random_wait.py b/t/random_wait.py
deleted file mode 100644
index 2cfc290..0000000
--- a/t/random_wait.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# SuperFastPython.com
-# example of waiting for all tasks to complete
-from random import random
-import asyncio
-
-total = 0
-
-
-async def task_coro(arg):
- value = random()
- total += value
- await asyncio.sleep(value)
- print(f'>{arg} done in {value}')
-
-
-async def main():
- tasks = [asyncio.create_task(task_coro(i)) for i in range(10)]
- done, pending = await asyncio.wait(tasks)
- print(f'All done. Total waiting time: {total}')
-
-
-asyncio.run(main())