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 11"""Test async/await integration"""
22
33from distutils .version import LooseVersion as V
4- import sys
4+ import time
55
66import pytest
77import IPython
@@ -46,8 +46,10 @@ def test_async_interrupt(asynclib, request):
4646 assert content ["status" ] == "ok" , content
4747
4848 flush_channels (KC )
49+ wait_time = 5
50+ t0 = time .time ()
4951 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 } )"
5153 )
5254 busy = KC .get_iopub_msg (timeout = TIMEOUT )
5355 validate_message (busy , "status" , msg_id )
@@ -61,7 +63,10 @@ def test_async_interrupt(asynclib, request):
6163
6264 KM .interrupt_kernel ()
6365 reply = KC .get_shell_msg ()["content" ]
66+ t1 = time .time ()
6467 assert reply ["status" ] == "error" , reply
6568 assert reply ["ename" ] in {"CancelledError" , "KeyboardInterrupt" }
69+ # interrupting should not wait for the coroutine execution to complete
70+ assert t1 - t0 < wait_time
6671
6772 flush_channels (KC )
You can’t perform that action at this time.
0 commit comments