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

Class ErrorFlightServer

python/pyarrow/tests/test_flight.py:410–456  ·  view source on GitHub ↗

A Flight server that uses all the Flight-specific errors.

Source from the content-addressed store, hash-verified

408
409
410class ErrorFlightServer(FlightServerBase):
411 """A Flight server that uses all the Flight-specific errors."""
412
413 @staticmethod
414 def error_cases():
415 return {
416 "internal": flight.FlightInternalError,
417 "timedout": flight.FlightTimedOutError,
418 "cancel": flight.FlightCancelledError,
419 "unauthenticated": flight.FlightUnauthenticatedError,
420 "unauthorized": flight.FlightUnauthorizedError,
421 "notimplemented": NotImplementedError,
422 "invalid": pa.ArrowInvalid,
423 "key": KeyError,
424 }
425
426 def do_action(self, context, action):
427 error_cases = ErrorFlightServer.error_cases()
428 if action.type in error_cases:
429 raise error_cases[action.type]("foo")
430 elif action.type == "protobuf":
431 err_msg = b'this is an error message'
432 raise flight.FlightUnauthorizedError("foo", err_msg)
433 raise NotImplementedError
434
435 def list_flights(self, context, criteria):
436 yield flight.FlightInfo(
437 pa.schema([]),
438 flight.FlightDescriptor.for_path('/foo'),
439 []
440 )
441 raise flight.FlightInternalError("foo")
442
443 def do_put(self, context, descriptor, reader, writer):
444 if descriptor.command == b"internal":
445 raise flight.FlightInternalError("foo")
446 elif descriptor.command == b"timedout":
447 raise flight.FlightTimedOutError("foo")
448 elif descriptor.command == b"cancel":
449 raise flight.FlightCancelledError("foo")
450 elif descriptor.command == b"unauthenticated":
451 raise flight.FlightUnauthenticatedError("foo")
452 elif descriptor.command == b"unauthorized":
453 raise flight.FlightUnauthorizedError("foo")
454 elif descriptor.command == b"protobuf":
455 err_msg = b'this is an error message'
456 raise flight.FlightUnauthorizedError("foo", err_msg)
457
458
459class ExchangeFlightServer(FlightServerBase):

Callers 2

test_roundtrip_errorsFunction · 0.85
test_extra_infoFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_roundtrip_errorsFunction · 0.68
test_extra_infoFunction · 0.68