summaryrefslogtreecommitdiff
path: root/tests/simult-busy.py
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-06-09 19:16:37 -0400
committerbd <bdunahu@operationnull.com>2025-06-09 19:16:37 -0400
commit5d7f40a890a1a1dd6dc7dc2982308932ba86cc42 (patch)
tree3ff61edbe6d7b4677312b22ef6984ad9cbc2eafb /tests/simult-busy.py
parent37e0520970e601a8342b2fa247e2ea710926a454 (diff)
Add naive async profiling functionality and proof of concept program
Diffstat (limited to 'tests/simult-busy.py')
-rw-r--r--tests/simult-busy.py25
1 files changed, 25 insertions, 0 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())