pyarrow.flight.FlightServerBase#
- classpyarrow.flight.FlightServerBase(location=None,auth_handler=None,tls_certificates=None,verify_client=None,root_certificates=None,middleware=None)#
Bases:
_WeakrefableA Flight service definition.
To start the server, create an instance of this class with anappropriate location. The server will be running as soon as theinstance is created; it is not required to call
serve().Override methods to define your Flight service.
- Parameters:
- location
str,tupleorLocationoptional, defaultNone Location to serve on. Either a gRPC URI likegrpc://localhost:port,a tuple of (host, port) pair, or a Location instance.If None is passed then the server will be started on localhost with asystem provided random port.
- auth_handler
ServerAuthHandleroptional, defaultNone An authentication mechanism to use. May be None.
- tls_certificates
listoptional, defaultNone A list of (certificate, key) pairs.
- verify_clientbool optional, default
False If True, then enable mutual TLS: require the client to presenta client certificate, and validate the certificate.
- root_certificates
bytesoptional, defaultNone If enabling mutual TLS, this specifies the PEM-encoded rootcertificate used to validate client certificates.
- middleware
dictoptional, defaultNone A dictionary of
ServerMiddlewareFactoryinstances. Thestring keys can be used to retrieve the middleware instance withinRPC handlers (seeServerCallContext.get_middleware()).
- location
- __init__(*args,**kwargs)#
Methods
__init__(*args, **kwargs)do_action(self, context, action)Execute a custom action.
do_exchange(self, context, descriptor, ...)Write data to a flight.
do_get(self, context, ticket)Write data to a flight.
do_put(self, context, descriptor, ...)Write data to a flight.
get_flight_info(self, context, descriptor)Get information about a flight.
get_schema(self, context, descriptor)Get the schema of a flight.
list_actions(self, context)List custom actions available on this server.
list_flights(self, context, criteria)List flights available on this service.
run(self)Block until the server shuts down.
serve(self)Block until the server shuts down.
shutdown(self)Shut down the server, blocking until current requests finish.
wait(self)Block until server is terminated with shutdown.
Attributes
Get the port that this server is listening on.
- do_action(self,context,action)#
Execute a custom action.
This method should return an iterator, or it should be agenerator. Applications should override this method toimplement their own behavior. The default method raises aNotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- action
Action The action to execute.
- context
- Returns:
- iterator of
bytes
- iterator of
- do_exchange(self,context,descriptor,reader,writer)#
Write data to a flight.
Applications should override this method to implement theirown behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- descriptor
FlightDescriptor The descriptor for the flight provided by the client.
- reader
MetadataRecordBatchReader A reader for data uploaded by the client.
- writer
MetadataRecordBatchWriter A writer to send responses to the client.
- context
- do_get(self,context,ticket)#
Write data to a flight.
Applications should override this method to implement theirown behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- ticket
Ticket The ticket for the flight.
- context
- Returns:
FlightDataStreamA stream of data to send back to the client.
- do_put(self,context,descriptor,MetadataRecordBatchReaderreader:MetadataRecordBatchReader,FlightMetadataWriterwriter:FlightMetadataWriter)#
Write data to a flight.
Applications should override this method to implement theirown behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- descriptor
FlightDescriptor The descriptor for the flight provided by the client.
- reader
MetadataRecordBatchReader A reader for data uploaded by the client.
- writer
FlightMetadataWriter A writer to send responses to the client.
- context
- get_flight_info(self,context,descriptor)#
Get information about a flight.
Applications should override this method to implement theirown behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- descriptor
FlightDescriptor The descriptor for the flight provided by the client.
- context
- Returns:
- get_schema(self,context,descriptor)#
Get the schema of a flight.
Applications should override this method to implement theirown behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- descriptor
FlightDescriptor The descriptor for the flight provided by the client.
- context
- Returns:
- list_actions(self,context)#
List custom actions available on this server.
Applications should override this method to implement theirown behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- context
- Returns:
- iterator of
ActionTypeortuple
- iterator of
- list_flights(self,context,criteria)#
List flights available on this service.
Applications should override this method to implement theirown behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext Common contextual information.
- criteria
bytes Filter criteria provided by the client.
- context
- Returns:
- iterator of
FlightInfo
- iterator of
- port#
Get the port that this server is listening on.
Returns a non-positive value if the operation is invalid(e.g. init() was not called or server is listening on a domainsocket).
- run(self)#
Block until the server shuts down.
Deprecated since version 0.15.0:Use the
FlightServer.servemethod instead
- serve(self)#
Block until the server shuts down.
This method only returns if shutdown() is called or a signal isreceived.
- shutdown(self)#
Shut down the server, blocking until current requests finish.
Do not call this directly from the implementation of a Flightmethod, as then the server will block forever waiting for thatrequest to finish. Instead, call this method from a backgroundthread.
This method should only be called once.
- wait(self)#
Block until server is terminated with shutdown.

