Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def retry_if_request_error(exception):
- if isinstance(exception,requests.exceptions.ConnectionError):
- return True
- elif isinstance(exception,requests.exceptions.ReadTimeout):
- return True
- else:
- return False
- #Use retry decorator to retry the function in the event of a network failure.
- @retry(retry_on_exception=retry_if_request_error,wait_exponential_multiplier=250,wait_exponential_max=30000,stop_max_delay=60000)
- def getSearchJSON(browser,search_url):
- search_page = browser.get(search_url, timeout=5)
- logging.debug("Got a search page going to return")
- return search_page
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement