Permalink
Browse files

Merge pull request #161 from casschin/get-response-code-timeout

Get response code timeout
  • Loading branch information...
2 parents 14dd4aa + bf81bb7 commit bbb784de3a2851b6736d7119fb208f30e728a3cd @bobsilverberg bobsilverberg committed Feb 4, 2013
Showing with 6 additions and 2 deletions.
  1. +6 −2 pages/page.py
View
@@ -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+)')
@@ -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.