-
Notifications
You must be signed in to change notification settings - Fork 30
Open
spraakbanken/stopit2
#3Description
Hi,
I'm having a bit of trouble nesting timeouts. Platforms tested:
- Windows 10 Pro
- Mac OSX
My shortest reproducible solution is here:
from stopit import ThreadingTimeout as Timeout
import time
def print_stuff(idx):
while True:
time.sleep(1)
print(idx)
def test_this():
t0 = time.time()
for idx in range(5):
with Timeout(5) as timeout_inner:
print_stuff(idx)
return time.time() - t0
with Timeout(10) as timeout_outer:
res = test_this()
assert res < 15Where the output is:
0
0
0
0
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-28-abee5adecac5> in <module>()
18 res = test_this()
19
---> 20 assert res < 15
AssertionError:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels