Add timeout

master
Tanner Collin 5 years ago
parent 50bf2e047b
commit cfc475a361
  1. 4
      wolframalpha/__init__.py

@ -21,7 +21,7 @@ class Client(object):
def __init__(self, app_id):
self.app_id = app_id
def query(self, input, params=(), **kwargs):
def query(self, input, timeout=5, params=(), **kwargs):
"""
Query Wolfram|Alpha using the v2.0 API
@ -50,7 +50,7 @@ class Client(object):
query = urllib.parse.urlencode(tuple(data))
url = 'https://api.wolframalpha.com/v2/query?' + query
resp = urllib.request.urlopen(url)
resp = urllib.request.urlopen(url, timeout=timeout)
assert resp.headers.get_content_type() == 'text/xml'
assert resp.headers.get_param('charset') == 'utf-8'
return Result(resp)

Loading…
Cancel
Save