Commit e3f4a105 by David Robinson

Merge pull request #51 from thelinuxkid/master

Add timeout to urlopen
parents 30ab2e11 8268c9f6
...@@ -23,6 +23,8 @@ API_ROOT = 'https://api.parse.com/1' ...@@ -23,6 +23,8 @@ API_ROOT = 'https://api.parse.com/1'
ACCESS_KEYS = {} ACCESS_KEYS = {}
CONNECTION_TIMEOUT = 60
def register(app_id, rest_key, **kw): def register(app_id, rest_key, **kw):
global ACCESS_KEYS global ACCESS_KEYS
ACCESS_KEYS = { ACCESS_KEYS = {
...@@ -87,7 +89,7 @@ class ParseBase(object): ...@@ -87,7 +89,7 @@ class ParseBase(object):
request.get_method = lambda: http_verb request.get_method = lambda: http_verb
try: try:
response = urlopen(request) response = urlopen(request, timeout=CONNECTION_TIMEOUT)
except HTTPError as e: except HTTPError as e:
exc = { exc = {
400: core.ResourceRequestBadRequest, 400: core.ResourceRequestBadRequest,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment