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