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