Skip to content

Commit

Permalink
Accept TTL as seconds and as a float
Browse files Browse the repository at this point in the history
  • Loading branch information
andronat committed Feb 12, 2015
1 parent ce3efb9 commit c5eacda
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kombu/messaging.py
Expand Up @@ -138,7 +138,7 @@ def publish(self, body, routing_key=None, delivery_mode=None,
connection is lost.
:keyword retry_policy: Retry configuration, this is the keywords
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.
:keyword \*\*properties: Additional message properties, see AMQP spec.
Expand All @@ -158,7 +158,7 @@ def publish(self, body, routing_key=None, delivery_mode=None,
delivery_mode = DELIVERY_MODES[delivery_mode]
properties['delivery_mode'] = delivery_mode
if expiration is not None:
properties['expiration'] = str(expiration)
properties['expiration'] = str(int(expiration*1000))

This comment has been minimized.

Copy link
@cooncesean

cooncesean Jun 12, 2018

I totally understand that this is a super old commit, but any guidance you might be able to provide would be incredibly helpful :)

QUESTION
What motivated the change to multiply the value of expiration by 1000? What does the 1000 represent (is it a conversion from microseconds to seconds?) What were old values of expiration?

CONTEXT
I'm using Celery (w/ a RedisBackEnd) + Kombu and am trying to track down the root cause of my custom task expiration values being ignored.

Thanks for all of your open source work to date --- no big rush on replying. Have a good day 👍

This comment has been minimized.

Copy link
@clokep

clokep Jun 12, 2018

It is converting from seconds to milliseconds. I think this is because it is what the RabbitMQ TTL extension uses.

This comment has been minimized.

Copy link
@andronat

andronat Jun 12, 2018

Author Contributor

Yep.


body, content_type, content_encoding = self._prepare(
body, serializer, content_type, content_encoding,
Expand Down

0 comments on commit c5eacda

Please sign in to comment.