Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. def retry_if_request_error(exception):
  2. if isinstance(exception,requests.exceptions.ConnectionError):
  3. return True
  4. elif isinstance(exception,requests.exceptions.ReadTimeout):
  5. return True
  6. else:
  7. return False
  8.  
  9. #Use retry decorator to retry the function in the event of a network failure.
  10. @retry(retry_on_exception=retry_if_request_error,wait_exponential_multiplier=250,wait_exponential_max=30000,stop_max_delay=60000)
  11. def getSearchJSON(browser,search_url):
  12. search_page = browser.get(search_url, timeout=5)
  13. logging.debug("Got a search page going to return")
  14. return search_page
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement