* Added support to use strings to specify both result_ttl and ttl.

* Added Days as possible timeout string (as 'd')
main
Yaniv Greenberg 8 years ago
parent fbe4cafe2a
commit 39e43207a6

@ -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,

@ -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

Loading…
Cancel
Save