This Page

mmf.async.queueserver

QueueServer(idict[, connections, logger]) Initialize the QueueServer.

Implementation of the QueueServer core functionality.

The QueueServer manages communication between the Connections and the Computation. The QueueServer periodically polls the {UpdateQueue}. If there is data waiting (in the form of a copy of the {IDict}), then it interprets this as an update notification, and it pushes this data to all of the subscribed Connections. It can monitor the status of the {UpdateQueue}, dumping data for example if the {UpdateQueue} is filling up too fast.

It also periodically polls the {RequestQueue} for direct requests of data from the Connections. It will consolidate such requests, then get the data directly from the {IDict} (because the {UpdateQueue} might contain older data) and sends it to the requesting connections.

The QueueServer is responsible for minimizing the blocking of the Computation. The only blocking will occur during direct access to the {IDict} object. To mitigate this, the QueueServer should consolidate all direct requests, and limit the frequency of direct requests. It should also monitor the size of the {UpdateQueue} to prevent memory problems (dropping data as required to keep the computation running smoothly.)

class mmf.async.queueserver.QueueServer(idict, connections=None, logger=None)[source]

Bases: object

Initialize the QueueServer.

idict: Dictionary to fetch requests from. connections: Set of connections to dispatch to. logger: A logging object.

Methods

onRequest() Called after a request has been put onto the request_queue.
onUpdate() Called after a pickled idict has been put onto the update_queue.
process_requests() Process requests on the request_queue.
process_updates() Process updates on the queue.
put_request(request) Put request on the RequestQueue.
put_update(idict) Put a copy of idict on the UdateQueue.
__init__(idict, connections=None, logger=None)[source]

Initialize the QueueServer.

idict: Dictionary to fetch requests from. connections: Set of connections to dispatch to. logger: A logging object.

onRequest()[source]

Called after a request has been put onto the request_queue.

Overload to suitable notify the controlling process that process_requests should be called.

onUpdate()[source]

Called after a pickled idict has been put onto the update_queue.

Overload to suitable notify the controlling process that process_updates should be called.

process_requests()[source]

Process requests on the request_queue.

process_updates()[source]

Process updates on the queue.

put_request(request)[source]

Put request on the RequestQueue.

put_update(idict)[source]

Put a copy of idict on the UdateQueue.

Called by the computation thread. This should block until idict is copied, then return as soon as possible, leaving the rest of the processing to another thread if possible.