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:1962–1991  ·  view source on GitHub ↗

Test canceling a DoGet operation from another thread.

()

Source from the content-addressed store, hash-verified

1960@pytest.mark.threading
1961@pytest.mark.slow
1962def test_cancel_do_get_threaded():
1963 """Test canceling a DoGet operation from another thread."""
1964 with SlowFlightServer() as server, \
1965 FlightClient(('localhost', server.port)) as client:
1966 reader = client.do_get(flight.Ticket(b'ints'))
1967
1968 read_first_message = threading.Event()
1969 stream_canceled = threading.Event()
1970 result_lock = threading.Lock()
1971 raised_proper_exception = threading.Event()
1972
1973 def block_read():
1974 reader.read_chunk()
1975 read_first_message.set()
1976 stream_canceled.wait(timeout=5)
1977 try:
1978 reader.read_chunk()
1979 except flight.FlightCancelledError:
1980 with result_lock:
1981 raised_proper_exception.set()
1982
1983 thread = threading.Thread(target=block_read, daemon=True)
1984 thread.start()
1985 read_first_message.wait(timeout=5)
1986 reader.cancel()
1987 stream_canceled.set()
1988 thread.join(timeout=1)
1989
1990 with result_lock:
1991 assert raised_proper_exception.is_set()
1992
1993
1994def 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