From 39e43207a642659f2830762c481ed358646fc1d8 Mon Sep 17 00:00:00 2001 From: Yaniv Greenberg Date: Mon, 8 May 2017 17:44:32 +0300 Subject: [PATCH] * Added support to use strings to specify both result_ttl and ttl. * Added Days as possible timeout string (as 'd') --- rq/queue.py | 2 ++ rq/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rq/queue.py b/rq/queue.py index 090997e..06998d9 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -192,6 +192,8 @@ class Queue(object): contain options for RQ itself. """ timeout = parse_timeout(timeout) or self._default_timeout + result_ttl = parse_timeout(result_ttl) + ttl = parse_timeout(ttl) job = self.job_class.create( func, args=args, kwargs=kwargs, connection=self.connection, diff --git a/rq/utils.py b/rq/utils.py index d7ec53c..92da521 100644 --- a/rq/utils.py +++ b/rq/utils.py @@ -253,12 +253,12 @@ def parse_timeout(timeout): timeout = int(timeout) except ValueError: digit, unit = timeout[:-1], (timeout[-1:]).lower() - unit_second = {'h': 3600, 'm': 60, 's': 1} + unit_second = {'d': 86400, 'h': 3600, 'm': 60, 's': 1} try: timeout = int(digit) * unit_second[unit] except (ValueError, KeyError): raise TimeoutFormatError('Timeout must be an integer or a string representing an integer, or ' - 'a string with format: digits + unit, unit can be "h", "m", "s", ' + 'a string with format: digits + unit, unit can be "d", "h", "m", "s", ' 'such as "1h", "23m".') return timeout