Skip to content

Commit

Permalink
retries should be warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesturk committed Jun 7, 2017
1 parent 8793e51 commit 5734b9f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scrapelib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
_user_agent = ' '.join(('scrapelib', __version__, requests.utils.default_user_agent()))


class NullHandler(logging.Handler):
def emit(self, record):
pass

_log = logging.getLogger('scrapelib')
_log.addHandler(NullHandler())
_log.addHandler(logging.NullHandler())


class HTTPMethodUnavailableError(requests.RequestException):
Expand Down Expand Up @@ -175,6 +171,10 @@ def request(self, method, url, retry_on_404=False, **kwargs):
# twice as long each time
wait = (self.retry_wait_seconds * (2 ** (tries - 1)))
_log.debug('sleeping for %s seconds before retry' % wait)
if exception_raised:
_log.warn('got %s sleeping for %s seconds before retry', exception_raised, wait)
else:
_log.warn('sleeping for %s seconds before retry', wait)
time.sleep(wait)

# out of the loop, either an exception was raised or we had a success
Expand Down

0 comments on commit 5734b9f

Please sign in to comment.