class documentation

class Queue: (source)

Constructor: Queue(directory)

View In Hierarchy

A queue for messages to be relayed.

Method __getstate__ Create a representation of the non-volatile state of the queue.
Method __init__ Initialize non-volatile state.
Method __setstate__ Restore the non-volatile state of the queue and recreate the volatile state.
Method addMessage Mark a message as waiting to be relayed unless it is in the process of being relayed.
Method createNewMessage Create a new message in the queue.
Method done Remove a message from the queue.
Method getEnvelope Get the envelope for a message.
Method getEnvelopeFile Return the envelope file for a message in the queue.
Method getPath Return the full base pathname of a message in the queue.
Method getRelayed Return the base filenames of messages in the process of being relayed.
Method getWaiting Return the base filenames of messages waiting to be relayed.
Method hasWaiting Return an indication of whether the queue has messages waiting to be relayed.
Method readDirectory Scan the message directory for new messages.
Method setRelaying Mark a message as being relayed.
Method setWaiting Mark a message as waiting to be relayed.
Instance Variable directory See __init__
Instance Variable n A number used to form unique filenames.
Instance Variable noisy A flag which determines whether informational log messages will be generated (True) or not (False).
Instance Variable relayed The base filenames of messages in the process of being relayed.
Instance Variable waiting The base filenames of messages waiting to be relayed.
Method _init Initialize volatile state.
def __getstate__(self): (source)

Create a representation of the non-volatile state of the queue.

Returns
dict mapping bytes to objectThe non-volatile state of the queue.
def __init__(self, directory): (source)

Initialize non-volatile state.

Parameters
directory:bytesThe pathname of the directory holding messages in the queue.
def __setstate__(self, state): (source)

Restore the non-volatile state of the queue and recreate the volatile state.

Parameters
state:dict mapping bytes to objectThe non-volatile state of the queue.
def addMessage(self, message): (source)

Mark a message as waiting to be relayed unless it is in the process of being relayed.

Parameters
message:bytesThe base filename of a message.
def createNewMessage(self): (source)

Create a new message in the queue.

Returns
2-tuple of (0) file, (1) FileMessageThe envelope file and a message receiver for a new message in the queue.
def done(self, message): (source)

Remove a message from the queue.

Parameters
message:bytesThe base filename of a message.
def getEnvelope(self, message): (source)

Get the envelope for a message.

Parameters
message:bytesThe base filename of a message.
Returns
list of two bytesA list containing the origination and destination addresses for the message.
def getEnvelopeFile(self, message): (source)

Return the envelope file for a message in the queue.

Parameters
message:bytesThe base filename of a message.
Returns
fileThe envelope file for the message.
def getPath(self, message): (source)

Return the full base pathname of a message in the queue.

Parameters
message:bytesThe base filename of a message.
Returns
bytesThe full base pathname of the message.
def getRelayed(self): (source)

Return the base filenames of messages in the process of being relayed.

Returns
list of bytesThe base filenames of messages in the process of being relayed.
def getWaiting(self): (source)

Return the base filenames of messages waiting to be relayed.

Returns
list of bytesThe base filenames of messages waiting to be relayed.
def hasWaiting(self): (source)

Return an indication of whether the queue has messages waiting to be relayed.

Returns
boolTrue if messages are waiting to be relayed. False otherwise.
def readDirectory(self): (source)

Scan the message directory for new messages.

def setRelaying(self, message): (source)

Mark a message as being relayed.

Parameters
message:bytesThe base filename of a message.
def setWaiting(self, message): (source)

Mark a message as waiting to be relayed.

Parameters
message:bytesThe base filename of a message.

A number used to form unique filenames.

A flag which determines whether informational log messages will be generated (True) or not (False).

The base filenames of messages in the process of being relayed.

The base filenames of messages waiting to be relayed.

def _init(self): (source)

Initialize volatile state.