Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge pull request #161 from casschin/get-response-code-timeout
Browse files Browse the repository at this point in the history
Get response code timeout
  • Loading branch information
bobsilverberg committed Feb 4, 2013
2 parents 14dd4aa + bf81bb7 commit bbb784d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import ElementNotVisibleException
from requests.exceptions import Timeout

http_regex = re.compile('https?://((\w+\.)+\w+\.\w+)')

Expand Down Expand Up @@ -100,5 +101,8 @@ def wait_for_ajax(self):
def get_response_code(self, url):
# return the response status
requests_config = {'max_retries': 5}
r = requests.get(url, verify=False, config=requests_config)
return r.status_code
try:
r = requests.get(url, verify=False, allow_redirects=True, config=requests_config, timeout=self.timeout)
return r.status_code
except Timeout:
return 408

0 comments on commit bbb784d

Please sign in to comment.