This module is available with the python-slimta[redis] package extra.

Package implementing the queue storage system using redis.

class slimta.redisstorage.RedisStorage([host='localhost'[, port=6379[, db=0[, password=None[, socket_timeout=None[, prefix='slimta:']]]]]])

Bases: slimta.queue.QueueStorage

QueueStorage mechanism that stores Envelope and queue metadata in redis hashes.

  • host – Hostname of the redis server to connect to.
  • port – Port to connect to.
  • db – Database number to create keys in.
  • password – Optional password to authenticate with.
  • socket_timeout – Timeout, in seconds, for socket operations. If the timeout is hit, socket.timeout is raised. None disables the timeout.
  • prefix (str) – Any key created is prefixed with this string.
write(envelope, timestamp)

Writes the given envelope to storage, along with the timestamp of its next delivery attempt. The number of delivery attempts asociated with the message should start at zero.

  • envelopeEnvelope object to write.
  • timestamp – Timestamp of message’s next delivery attempt.

Unique identifier string for the message in queue.



set_timestamp(id, timestamp)

Sets a new timestamp for the message’s next delivery attempt.

  • id – The unique identifier string for the message.
  • timestamp – The new delivery attempt timestamp.



Increments the number of delivery attempts associated with the message.

Parameters:id – The unique identifier string for the message.
Returns:The new number of message delivery attempts.
set_recipients_delivered(id, rcpt_indexes)

New in version 1.1.0.

Marks the given recipients from the original envelope as already-delivered, meaning they will be skipped by future relay attempts.

  • id – The unique identifier string for the message.
  • rcpt_indexes – List of indexes in the original envelope’s recipients list to mark as delivered.



Loads all queued messages from the storage engine, such that the Queue can be aware of all upcoming delivery attempts.

Returns:Iterable that yields tuples of the form (timestamp, id) for each message in storage.

Returns the Envelope object associated with the given unique identifier sring.

The envelope’s recipients should not include those marked as delivered by set_recipients_delivered().

Parameters:id – The unique identifier string of the requested Envelope.
Returns:Tuple with the Envelope object and number of attempts.
Raises:KeyError, QueueError

Removes the Envelope associated with the given unique identifier string from queue storage. This is typically used when the message has been successfully delivered or delivery has permanently failed.

Parameters:id – The unique identifier string of the Envelope to remove.

If messages are not being delivered from the same process in which they were received, the storage mechanism needs a way to wait until it is notified that a new message has been stored.

Returns:An iterable or generator producing tuples with the timestamp and unique identifier string of a new message in storage. When the iterable or generator is exhausted, wait() is simply called again.