Commit 037aceaf authored by Olivier Da Rocha's avatar Olivier Da Rocha Committed by ntome

[browser/exceptions] BrowserTooManyRequests: Remove class attributes for date helpers

The dates where evaluated at startup, this meant NEXT_DAY and NEXT_24H
were fixed since the browser creation not when raising the exception
parent 408fcb7f
......@@ -48,12 +48,6 @@ class BrowserTooManyRequests(BrowserUnavailable):
The module should set the next_try if possible, else it is set to 24h.
"""
# next day at 00h00
NEXT_DAY = datetime.date.today() + relativedelta(days=1)
# in exactly 24h
NEXT_24H = datetime.datetime.now() + relativedelta(days=1)
def __init__(self, message='', next_try=None):
super(BrowserTooManyRequests, self).__init__(message)
......@@ -61,7 +55,7 @@ class BrowserTooManyRequests(BrowserUnavailable):
next_try = datetime.datetime.combine(next_try, datetime.datetime.min.time())
if next_try is None:
next_try = BrowserTooManyRequests.NEXT_24H
next_try = datetime.datetime.now() + relativedelta(days=1)
if not isinstance(next_try, datetime.datetime):
raise TypeError('next_try value should be a datetime.')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment