A Flight server that delays its responses to test timeouts.
| 385 | |
| 386 | |
| 387 | class SlowFlightServer(FlightServerBase): |
| 388 | """A Flight server that delays its responses to test timeouts.""" |
| 389 | |
| 390 | def do_get(self, context, ticket): |
| 391 | return flight.GeneratorStream(pa.schema([('a', pa.int32())]), |
| 392 | self.slow_stream()) |
| 393 | |
| 394 | def do_action(self, context, action): |
| 395 | time.sleep(0.5) |
| 396 | return [] |
| 397 | |
| 398 | @staticmethod |
| 399 | def slow_stream(): |
| 400 | data1 = [pa.array([-10, -5, 0, 5, 10], type=pa.int32())] |
| 401 | yield pa.Table.from_arrays(data1, names=['a']) |
| 402 | # The second message should never get sent; the client should |
| 403 | # cancel before we send this |
| 404 | time.sleep(10) |
| 405 | yield pa.Table.from_arrays(data1, names=['a']) |
| 406 | |
| 407 | |
| 408 | class ErrorFlightServer(FlightServerBase): |
no outgoing calls