pyarrow.flight.FlightServerBase#

class pyarrow.flight.FlightServerBase(location=None, auth_handler=None, tls_certificates=None, verify_client=None, root_certificates=None, middleware=None)#

Bases: pyarrow.lib._Weakrefable

A Flight service definition.

To start the server, create an instance of this class with an appropriate location. The server will be running as soon as the instance is created; it is not required to call serve().

Override methods to define your Flight service.

Parameters
locationstr, tuple or Location optional, default None

Location to serve on. Either a gRPC URI like grpc://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 a system provided random port.

auth_handlerServerAuthHandler optional, default None

An authentication mechanism to use. May be None.

tls_certificateslist optional, default None

A list of (certificate, key) pairs.

verify_clientbool optional, default False

If True, then enable mutual TLS: require the client to present a client certificate, and validate the certificate.

root_certificatesbytes optional, default None

If enabling mutual TLS, this specifies the PEM-encoded root certificate used to validate client certificates.

middlewarelist optional, default None

A dictionary of ServerMiddlewareFactory items. The keys are used to retrieve the middleware instance during calls (see ServerCallContext.get_middleware()).

__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

port

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 a generator. Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

actionAction

The action to execute.

Returns
iterator of bytes
do_exchange(self, context, descriptor, reader, writer)#

Write data to a flight.

Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

descriptorFlightDescriptor

The descriptor for the flight provided by the client.

readerMetadataRecordBatchReader

A reader for data uploaded by the client.

writerMetadataRecordBatchWriter

A writer to send responses to the client.

do_get(self, context, ticket)#

Write data to a flight.

Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

ticketTicket

The ticket for the flight.

Returns
FlightDataStream

A stream of data to send back to the client.

do_put(self, context, descriptor, MetadataRecordBatchReader reader: MetadataRecordBatchReader, FlightMetadataWriter writer: FlightMetadataWriter)#

Write data to a flight.

Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

descriptorFlightDescriptor

The descriptor for the flight provided by the client.

readerMetadataRecordBatchReader

A reader for data uploaded by the client.

writerFlightMetadataWriter

A writer to send responses to the client.

get_flight_info(self, context, descriptor)#

Get information about a flight.

Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

descriptorFlightDescriptor

The descriptor for the flight provided by the client.

Returns
FlightInfo
get_schema(self, context, descriptor)#

Get the schema of a flight.

Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

descriptorFlightDescriptor

The descriptor for the flight provided by the client.

Returns
Schema
list_actions(self, context)#

List custom actions available on this server.

Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

Returns
iterator of ActionType or tuple
list_flights(self, context, criteria)#

List flights available on this service.

Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.

Parameters
contextServerCallContext

Common contextual information.

criteriabytes

Filter criteria provided by the client.

Returns
iterator of FlightInfo
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 domain socket).

run(self)#

Block until the server shuts down.

Deprecated since version 0.15.0: Use the FlightServer.serve method instead

serve(self)#

Block until the server shuts down.

This method only returns if shutdown() is called or a signal a received.

shutdown(self)#

Shut down the server, blocking until current requests finish.

Do not call this directly from the implementation of a Flight method, as then the server will block forever waiting for that request to finish. Instead, call this method from a background thread.

wait(self)#

Block until server is terminated with shutdown.