Merge pull request #832 from yaniv-g/master

Expand timeout string feature to both result_ttl and ttl, and add days possibility.
main
Selwin Ong 8 years ago committed by GitHub
commit d71a6c2ece

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