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

Commit

Permalink
Add timeout to urlopen
Browse files Browse the repository at this point in the history
- Connection can sometimes hang forever on SSL handshake
  • Loading branch information
thelinuxkid committed Aug 4, 2014
1 parent 30ab2e1 commit 8268c9f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parse_rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
ACCESS_KEYS = {}


CONNECTION_TIMEOUT = 60

def register(app_id, rest_key, **kw):
global ACCESS_KEYS
ACCESS_KEYS = {
Expand Down Expand Up @@ -87,7 +89,7 @@ def execute(cls, uri, http_verb, extra_headers=None, batch=False, **kw):
request.get_method = lambda: http_verb

try:
response = urlopen(request)
response = urlopen(request, timeout=CONNECTION_TIMEOUT)
except HTTPError as e:
exc = {
400: core.ResourceRequestBadRequest,
Expand Down

0 comments on commit 8268c9f

Please sign in to comment.