summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/simult-busy.py25
-rw-r--r--tests/simult.py16
2 files changed, 36 insertions, 5 deletions
diff --git a/tests/simult-busy.py b/tests/simult-busy.py
new file mode 100644
index 0000000..4cc4b2a
--- /dev/null
+++ b/tests/simult-busy.py
@@ -0,0 +1,25 @@
+import asyncio
+import time
+
+async def busy_task():
+ await asyncio.sleep(3.0)
+ return 1
+
+async def main():
+ tasks = [asyncio.create_task(busy_task()) for i in range(5)]
+
+ start_time = time.time()
+ try:
+ # this is to prevent waiting in 'select' all day,
+ # which makes the python intepreter not respond to
+ # mini-scalene / SCALENE
+ while True:
+ if time.time() - start_time > 3.5:
+ break
+ await asyncio.sleep(0) # yield
+ except KeyboardInterrupt:
+ pass
+ finally:
+ print("Done.")
+
+asyncio.run(main())
diff --git a/tests/simult.py b/tests/simult.py
index 6228596..61a3792 100644
--- a/tests/simult.py
+++ b/tests/simult.py
@@ -1,14 +1,20 @@
import asyncio
+import time
-async def count():
- print("before")
- await asyncio.sleep(1)
- print("after")
+async def count(x):
+ i = 0
+ await asyncio.sleep(2)
+ while i < 100000:
+ z = x * x
+ z = z * z
+ z = z * z
+ i += 1
+ return z
async def main():
- await asyncio.gather(count(), count(), count())
+ await asyncio.gather(count(1), count(2), count(3))
print("done")
asyncio.run(main())