MCPcopy Create free account
hub / github.com/apache/arrow / test_cancel_do_get_threaded

Function test_cancel_do_get_threaded

python/pyarrow/tests/test_flight.py:1924–1953  ·  view source on GitHub ↗

Test canceling a DoGet operation from another thread.

()

Source from the content-addressed store, hash-verified

1922@pytest.mark.threading
1923@pytest.mark.slow
1924def test_cancel_do_get_threaded():
1925 """Test canceling a DoGet operation from another thread."""
1926 with SlowFlightServer() as server, \
1927 FlightClient(('localhost', server.port)) as client:
1928 reader = client.do_get(flight.Ticket(b'ints'))
1929
1930 read_first_message = threading.Event()
1931 stream_canceled = threading.Event()
1932 result_lock = threading.Lock()
1933 raised_proper_exception = threading.Event()
1934
1935 def block_read():
1936 reader.read_chunk()
1937 read_first_message.set()
1938 stream_canceled.wait(timeout=5)
1939 try:
1940 reader.read_chunk()
1941 except flight.FlightCancelledError:
1942 with result_lock:
1943 raised_proper_exception.set()
1944
1945 thread = threading.Thread(target=block_read, daemon=True)
1946 thread.start()
1947 read_first_message.wait(timeout=5)
1948 reader.cancel()
1949 stream_canceled.set()
1950 thread.join(timeout=1)
1951
1952 with result_lock:
1953 assert raised_proper_exception.is_set()
1954
1955
1956def test_streaming_do_action():

Callers

nothing calls this directly

Calls 8

FlightClientClass · 0.90
SlowFlightServerClass · 0.85
cancelMethod · 0.80
do_getMethod · 0.45
LockMethod · 0.45
startMethod · 0.45
setMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected