Package lamson :: Module queue :: Class Queue
[hide private]
[frames] | no frames]

Class Queue

source code


Provides a simplified API for dealing with 'queues' in Lamson. It currently just supports maildir queues since those are the most robust, but could implement others later.

Instance Methods [hide private]
 
__init__(self, queue_dir, safe=False, pop_limit=0, oversize_dir=None)
This gives the Maildir queue directory to use, and whether you want this Queue to use the SafeMaildir variant which hashes the hostname so you can expose it publicly.
source code
 
push(self, message)
Pushes the message onto the queue.
source code
 
pop(self)
Pops a message off the queue, order is not really maintained like a stack.
source code
 
get(self, key)
Get the specific message referenced by the key.
source code
 
remove(self, key)
Removes the queue, but not returned.
source code
 
count(self)
Returns the number of messages in the queue.
source code
 
clear(self)
Clears out the contents of the entire queue.
source code
 
keys(self)
Returns the keys in the queue.
source code
 
oversize(self, key) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, queue_dir, safe=False, pop_limit=0, oversize_dir=None)
(Constructor)

source code 

This gives the Maildir queue directory to use, and whether you want this Queue to use the SafeMaildir variant which hashes the hostname so you can expose it publicly.

The pop_limit and oversize_queue both set a upper limit on the mail you pop out of the queue. The size is checked before any Lamson processing is done and is based on the size of the file on disk. The purpose is to prevent people from sending 10MB attachments. If a message is over the pop_limit then it is placed into the oversize_dir (which should be a maildir).

The oversize protection only works on pop messages off, not putting them in, get, or any other call. If you use get you can use self.oversize to also check if it's oversize manually.

Overrides: object.__init__

push(self, message)

source code 

Pushes the message onto the queue. Remember the order is probably not maintained. It returns the key that gets created.

pop(self)

source code 

Pops a message off the queue, order is not really maintained like a stack.

It returns a (key, message) tuple for that item.

get(self, key)

source code 

Get the specific message referenced by the key. The message is NOT removed from the queue.

remove(self, key)

source code 

Removes the queue, but not returned.

count(self)

source code 

Returns the number of messages in the queue.

clear(self)

source code 

Clears out the contents of the entire queue. Warning: This could be horribly inefficient since it basically pops until the queue is empty.

keys(self)

source code 

Returns the keys in the queue.

oversize(self, key)

source code