File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11"""Test async/await integration"""
22
3+ import time
4+
35import pytest
46
57from .test_message_spec import validate_message
@@ -43,7 +45,9 @@ def test_async_interrupt(asynclib, request):
4345 assert content ["status" ] == "ok" , content
4446
4547 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 } )" )
4751 busy = KC .get_iopub_msg (timeout = TIMEOUT )
4852 validate_message (busy , "status" , msg_id )
4953 assert busy ["content" ]["execution_state" ] == "busy"
@@ -56,7 +60,10 @@ def test_async_interrupt(asynclib, request):
5660
5761 KM .interrupt_kernel ()
5862 reply = KC .get_shell_msg ()["content" ]
63+ t1 = time .time ()
5964 assert reply ["status" ] == "error" , reply
6065 assert reply ["ename" ] in {"CancelledError" , "KeyboardInterrupt" }
66+ # interrupting should not wait for the coroutine execution to complete
67+ assert t1 - t0 < wait_time
6168
6269 flush_channels (KC )
You can’t perform that action at this time.
0 commit comments