b.s.m.SmartServerStreamMedium(SmartMedium) : class documentation

Part of bzrlib.smart.medium View In Hierarchy

Known subclasses: bzrlib.smart.medium.SmartServerPipeStreamMedium, bzrlib.smart.medium.SmartServerSocketStreamMedium

Handles smart commands coming over a stream.

The stream may be a pipe connected to sshd, or a tcp socket, or an in-process fifo for testing.

One instance is created for each connected client; it can serve multiple requests in the lifetime of the connection.

The server passes requests through to an underlying backing transport, which will typically be a LocalTransport looking at the server's filesystem.

Instance Variables_push_back_buffera str of bytes that have been read from the stream but not used yet, or None if there are no buffered bytes. Subclasses should make sure to exhaust this buffer before reading more bytes from the stream. See also the _push_back method.
Method __init__ Construct new server.
Method serve Serve requests until the client disconnects.
Method terminate_due_to_error Called when an unhandled exception from the protocol occurs.
Method _stop_gracefully When we finish this message, stop looking for more.
Method _disconnect_client Close the current connection. We stopped due to a timeout/etc.
Method _wait_for_bytes_with_timeout Wait for more bytes to be read, but timeout if none available.
Method _build_protocol Identifies the version of the incoming request, and returns an
Method _wait_on_descriptor select() on a file descriptor, waiting for nonblocking read()
Method _serve_one_request Read one request from input, process, send back a response.
Method _read_bytes Get some bytes from the medium.

Inherited from SmartMedium:

Method read_bytes Read some bytes from this medium.
Method _push_back Return unused bytes to the medium, because they belong to the next
Method _get_push_back_buffer Undocumented
Method _get_line Read bytes from this request's response until a newline byte.
Method _report_activity Notify that this medium has activity.
def __init__(self, backing_transport, root_client_path='/', timeout=None):
Construct new server.
Parametersbacking_transportTransport for the directory served.
def serve(self):
Serve requests until the client disconnects.
def _stop_gracefully(self):
When we finish this message, stop looking for more.
def _disconnect_client(self):
Close the current connection. We stopped due to a timeout/etc.
def _wait_for_bytes_with_timeout(self, timeout_seconds):
Wait for more bytes to be read, but timeout if none available.

This allows us to detect idle connections, and stop trying to read from them, without setting the socket itself to non-blocking. This also allows us to specify when we watch for idle timeouts.

ReturnsDid we timeout? (True if we timed out, False if there is data to be read)
def _build_protocol(self):
Identifies the version of the incoming request, and returns an a protocol object that can interpret it.

If more bytes than the version prefix of the request are read, they will be fed into the protocol before it is returned.

Returnsa SmartServerRequestProtocol.
def _wait_on_descriptor(self, fd, timeout_seconds):
select() on a file descriptor, waiting for nonblocking read()

This will raise a ConnectionTimeout exception if we do not get a readable handle before timeout_seconds. :return: None

def _serve_one_request(self, protocol):
Read one request from input, process, send back a response.
Parametersprotocola SmartServerRequestProtocol.
def terminate_due_to_error(self):
Called when an unhandled exception from the protocol occurs.
def _read_bytes(self, desired_count):
Get some bytes from the medium.
Parametersdesired_countnumber of bytes we want to read.
API Documentation for Bazaar, generated by pydoctor at 2019-09-23 00:31:07.