b.s.m.SmartClientMediumRequest(object) : class documentation

Part of bzrlib.smart.medium View In Hierarchy

Known subclasses: bzrlib.smart.medium.SmartClientStreamMediumRequest, bzrlib.transport.http.SmartClientHTTPMediumRequest

A request on a SmartClientMedium.

Each request allows bytes to be provided to it via accept_bytes, and then the response bytes to be read via read_bytes.

For instance: request.accept_bytes('123') request.finished_writing() result = request.read_bytes(3) request.finished_reading()

It is up to the individual SmartClientMedium whether multiple concurrent requests can exist. See SmartClientMedium.get_request to obtain instances of SmartClientMediumRequest, and the concrete Medium you are using for details on concurrency and pipelining.

Method __init__ Construct a SmartClientMediumRequest for the medium medium.
Method accept_bytes Accept bytes for inclusion in this request.
Method finished_reading Inform the request that all desired data has been read.
Method finished_writing Finish the writing phase of this request.
Method read_bytes Read bytes from this requests response.
Method read_line Undocumented
Method _accept_bytes Helper for accept_bytes.
Method _finished_reading Helper for finished_reading.
Method _finished_writing Helper for finished_writing.
Method _read_bytes Helper for SmartClientMediumRequest.read_bytes.
Method _read_line Helper for SmartClientMediumRequest.read_line.
def __init__(self, medium):
Construct a SmartClientMediumRequest for the medium medium.
def accept_bytes(self, bytes):
Accept bytes for inclusion in this request.

This method may not be called after finished_writing() has been called. It depends upon the Medium whether or not the bytes will be immediately transmitted. Message based Mediums will tend to buffer the bytes until finished_writing() is called.

ParametersbytesA bytestring.
def _accept_bytes(self, bytes):
Helper for accept_bytes.

Accept_bytes checks the state of the request to determing if bytes should be accepted. After that it hands off to _accept_bytes to do the actual acceptance.

def finished_reading(self):
Inform the request that all desired data has been read.

This will remove the request from the pipeline for its medium (if the medium supports pipelining) and any further calls to methods on the request will raise ReadingCompleted.

def _finished_reading(self):
Helper for finished_reading.

finished_reading checks the state of the request to determine if finished_reading is allowed, and if it is hands off to _finished_reading to perform the action.

def finished_writing(self):
Finish the writing phase of this request.

This will flush all pending data for this request along the medium. After calling finished_writing, you may not call accept_bytes anymore.

def _finished_writing(self):
Helper for finished_writing.

finished_writing checks the state of the request to determine if finished_writing is allowed, and if it is hands off to _finished_writing to perform the action.

def read_bytes(self, count):
Read bytes from this requests response.

This method will block and wait for count bytes to be read. It may not be invoked until finished_writing() has been called - this is to ensure a message-based approach to requests, for compatibility with message based mediums like HTTP.

def _read_bytes(self, count):
Helper for SmartClientMediumRequest.read_bytes.

read_bytes checks the state of the request to determing if bytes should be read. After that it hands off to _read_bytes to do the actual read.

By default this forwards to self._medium.read_bytes because we are operating on the medium's stream.

def read_line(self):
Undocumented
def _read_line(self):
Helper for SmartClientMediumRequest.read_line.

By default this forwards to self._medium._get_line because we are operating on the medium's stream.

API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.