Debian Codegraph @

tests/isolated/zero_second_sleep.py

raw
1 import eventlet
2
3 eventlet.sleep(0)
4 eventlet.monkey_patch()
5
6 from eventlet.hubs import get_hub
7 import time
8
9 FAILURES = []
10
11
12 def zero_second_sleep():
13 try:
14 eventlet.sleep(0)
15 time.sleep(0)
16 except RuntimeError:
17 FAILURES.append(1)
18 raise
19
20
21 # Simulate sleep(0) being called from a trampoline function. Or try to, anyway,
22 # not really sure if this matches the original reported bug but it does at
23 # least trigger the RuntimeError about blocking functions lacking the fix for
24 # sleep(0).
25 get_hub().schedule_call_local(0, zero_second_sleep)
26 zero_second_sleep()
27
28 if FAILURES:
29 raise RuntimeError("There were failures")
30
31 print("pass")