Skip to content

Commit

Permalink
Sleep 0.2 before auto retry
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlatr committed Aug 3, 2020
1 parent 262a578 commit c2e79ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions msiempy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,13 @@ def esm_request(self, method, data, http='post', callback=None, raw=False, secur
# Invalid session handler -> re-login
if any([match in result.text for match in ['ERROR_InvalidSession', 'ERROR_INVALID_SESSION',
'Not Authorized User', 'Invalid Session', 'Username and password cannot be null']]):
error = NitroError('Authentication error with method ({}) and data : {} logging in and retrying. From requests.HTTPError {} {}'.format(
error = NitroError('Authentication error with method ({}) and data : {} logging in and retrying esm_request(). From requests.HTTPError {} {}'.format(
method, data, e, result.text))
log.warning(error)
self.logged_in=False
self.login()

else: log.warning('An HTTP error occured ({} {}), retrying request'.format(e, result.text))
else: log.warning('An HTTP error occured ({} {}), retrying esm_request()'.format(e, result.text))

# Retry request
time.sleep(0.2)
Expand Down
1 change: 1 addition & 0 deletions msiempy/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def qry_load_data(self, retry=1, wait_timeout_sec=120):
# or isinstance(error, TimeoutError)) ):
if retry > 0:
log.warning('Retring qry_load_data() after error: '+str(error))
time.sleep(0.2)
return self.qry_load_data(retry=retry-1)
else: raise

Expand Down

0 comments on commit c2e79ab

Please sign in to comment.