File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
"""Test async/await integration"""
2
2
3
+ import time
4
+
3
5
import pytest
4
6
5
7
from .test_message_spec import validate_message
@@ -43,7 +45,9 @@ def test_async_interrupt(asynclib, request):
43
45
assert content ["status" ] == "ok" , content
44
46
45
47
flush_channels (KC )
46
- msg_id = KC .execute (f"print('begin'); import { asynclib } ; await { asynclib } .sleep(5)" )
48
+ wait_time = 5
49
+ t0 = time .time ()
50
+ msg_id = KC .execute (f"print('begin'); import { asynclib } ; await { asynclib } .sleep({ wait_time } )" )
47
51
busy = KC .get_iopub_msg (timeout = TIMEOUT )
48
52
validate_message (busy , "status" , msg_id )
49
53
assert busy ["content" ]["execution_state" ] == "busy"
@@ -56,7 +60,10 @@ def test_async_interrupt(asynclib, request):
56
60
57
61
KM .interrupt_kernel ()
58
62
reply = KC .get_shell_msg ()["content" ]
63
+ t1 = time .time ()
59
64
assert reply ["status" ] == "error" , reply
60
65
assert reply ["ename" ] in {"CancelledError" , "KeyboardInterrupt" }
66
+ # interrupting should not wait for the coroutine execution to complete
67
+ assert t1 - t0 < wait_time
61
68
62
69
flush_channels (KC )
You can’t perform that action at this time.
0 commit comments