pyarrow.flight.FlightServerBase#

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

Bases:_Weakrefable

A 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 callserve().

Override methods to define your Flight service.

Parameters:
locationstr,tuple orLocation optional, 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_handlerServerAuthHandler optional, defaultNone

An authentication mechanism to use. May be None.

tls_certificateslist optional, defaultNone

A list of (certificate, key) pairs.

verify_clientbool optional, defaultFalse

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

root_certificatesbytes optional, defaultNone

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

middlewaredict optional, defaultNone

A dictionary ofServerMiddlewareFactory instances. Thestring keys can be used to retrieve the middleware instance withinRPC handlers (seeServerCallContext.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 agenerator. Applications should override this method toimplement their own behavior. The default method raises aNotImplementedError.

Parameters:
contextServerCallContext

Common contextual information.

actionAction

The action to execute.

Returns:
iterator ofbytes
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:
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 theirown 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,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:
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 theirown 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 theirown 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 theirown behavior. The default method raises a NotImplementedError.

Parameters:
contextServerCallContext

Common contextual information.

Returns:
iterator ofActionType ortuple
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:
contextServerCallContext

Common contextual information.

criteriabytes

Filter criteria provided by the client.

Returns:
iterator ofFlightInfo
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 theFlightServer.serve method 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.