File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import duckdb
22import time
33import pytest
4-
54import platform
65import threading
76import _thread as thread
87
98
109def send_keyboard_interrupt ():
11- # Wait a little, so we're sure the 'execute' has started
1210 time .sleep (0.1 )
13- # Send an interrupt to the main thread
1411 thread .interrupt_main ()
1512
1613
1714class TestQueryInterruption (object ):
15+
1816 @pytest .mark .xfail (
1917 condition = platform .system () == "Emscripten" ,
2018 reason = "Emscripten builds cannot use threads" ,
2119 )
22- def test_query_interruption (self ):
20+ @pytest .mark .timeout (15 )
21+ def test_keyboard_interruption (self ):
2322 con = duckdb .connect ()
2423 thread = threading .Thread (target = send_keyboard_interrupt )
2524 # Start the thread
2625 thread .start ()
2726 try :
28- res = con .execute ('select count(*) from range(100000000000)' ).fetchall ()
29- except RuntimeError :
30- # If this is not reached, we could not cancel the query before it completed
31- # indicating that the query interruption functionality is broken
32- assert True
33- except KeyboardInterrupt :
34- pytest .fail ()
35- thread .join ()
27+ with pytest .raises ((KeyboardInterrupt , RuntimeError )):
28+ res = con .execute ('select * from range(100000) t1,range(100000) t2' ).fetchall ()
29+ finally :
30+ # Ensure the thread completes regardless of what happens
31+ thread .join ()
You can’t perform that action at this time.
0 commit comments