Accept TTL as seconds and as a float

This commit is contained in:
Anastasis Andronidis 2015-02-12 15:33:22 +01:00
parent ce3efb951a
commit c5eacdafae
1 changed files with 2 additions and 2 deletions

View File

@ -138,7 +138,7 @@ class Producer(object):
connection is lost. connection is lost.
:keyword retry_policy: Retry configuration, this is the keywords :keyword retry_policy: Retry configuration, this is the keywords
supported by :meth:`~kombu.Connection.ensure`. supported by :meth:`~kombu.Connection.ensure`.
:keyword expiration: A TTL can be specified on a per-message basis. :keyword expiration: A TTL in seconds can be specified per message.
Default is no expiration. Default is no expiration.
:keyword \*\*properties: Additional message properties, see AMQP spec. :keyword \*\*properties: Additional message properties, see AMQP spec.
@ -158,7 +158,7 @@ class Producer(object):
delivery_mode = DELIVERY_MODES[delivery_mode] delivery_mode = DELIVERY_MODES[delivery_mode]
properties['delivery_mode'] = delivery_mode properties['delivery_mode'] = delivery_mode
if expiration is not None: if expiration is not None:
properties['expiration'] = str(expiration) properties['expiration'] = str(int(expiration*1000))
body, content_type, content_encoding = self._prepare( body, content_type, content_encoding = self._prepare(
body, serializer, content_type, content_encoding, body, serializer, content_type, content_encoding,