Test canceling a DoGet operation from another thread.
()
| 1922 | @pytest.mark.threading |
| 1923 | @pytest.mark.slow |
| 1924 | def 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 | |
| 1956 | def test_streaming_do_action(): |
nothing calls this directly
no test coverage detected