Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pywmata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class Wmata(object):

base_url = 'http://api.wmata.com/%(svc)s.svc/json/%(endpoint)s'

def __init__(self, apikey):
def __init__(self, apikey, timeout=30):
self.apikey = apikey
self.timeout = timeout

def _build_url(self, svc, endpoint, query={}):
query.update({'api_key': self.apikey})
Expand All @@ -27,7 +28,7 @@ def _build_url(self, svc, endpoint, query={}):

def _get(self, svc, endpoint, query={}):
self.url = self._build_url(svc, endpoint, query)
response = urlopen(self.url)
response = urlopen(self.url, None, self.timeout)

if response.msg == 'OK':
self.data = json.loads(response.read())
Expand Down