@@ -59,10 +59,11 @@ class OpenTok(object):
5959 TOKEN_SENTINEL = 'T1=='
6060 """For internal use."""
6161
62- def __init__ (self , api_key , api_secret , api_url = 'https://api.opentok.com' ):
62+ def __init__ (self , api_key , api_secret , api_url = 'https://api.opentok.com' , timeout = None ):
6363 self .api_key = str (api_key )
6464 self .api_secret = api_secret
6565 self .api_url = api_url
66+ self .timeout = timeout
6667 self ._proxies = None
6768
6869 @property
@@ -263,7 +264,7 @@ def create_session(self, location=None, media_mode=MediaModes.relayed, archive_m
263264 options [u ('location' )] = location
264265
265266 try :
266- response = requests .post (self .session_url (), data = options , headers = self .headers (), proxies = self .proxies )
267+ response = requests .post (self .session_url (), data = options , headers = self .headers (), proxies = self .proxies , timeout = self . timeout )
267268 response .encoding = 'utf-8'
268269
269270 if response .status_code == 403 :
@@ -351,7 +352,7 @@ def start_archive(self, session_id, has_audio=True, has_video=True, name=None, o
351352 'outputMode' : output_mode .value
352353 }
353354
354- response = requests .post (self .archive_url (), data = json .dumps (payload ), headers = self .archive_headers (), proxies = self .proxies )
355+ response = requests .post (self .archive_url (), data = json .dumps (payload ), headers = self .archive_headers (), proxies = self .proxies , timeout = self . timeout )
355356
356357 if response .status_code < 300 :
357358 return Archive (self , response .json ())
@@ -377,7 +378,7 @@ def stop_archive(self, archive_id):
377378
378379 :rtype: The Archive object corresponding to the archive being stopped.
379380 """
380- response = requests .post (self .archive_url (archive_id ) + '/stop' , headers = self .archive_headers (), proxies = self .proxies )
381+ response = requests .post (self .archive_url (archive_id ) + '/stop' , headers = self .archive_headers (), proxies = self .proxies , timeout = self . timeout )
381382
382383 if response .status_code < 300 :
383384 return Archive (self , response .json ())
@@ -400,7 +401,7 @@ def delete_archive(self, archive_id):
400401
401402 :param String archive_id: The archive ID of the archive to be deleted.
402403 """
403- response = requests .delete (self .archive_url (archive_id ), headers = self .archive_headers (), proxies = self .proxies )
404+ response = requests .delete (self .archive_url (archive_id ), headers = self .archive_headers (), proxies = self .proxies , timeout = self . timeout )
404405
405406 if response .status_code < 300 :
406407 pass
@@ -418,7 +419,7 @@ def get_archive(self, archive_id):
418419
419420 :rtype: The Archive object.
420421 """
421- response = requests .get (self .archive_url (archive_id ), headers = self .archive_headers (), proxies = self .proxies )
422+ response = requests .get (self .archive_url (archive_id ), headers = self .archive_headers (), proxies = self .proxies , timeout = self . timeout )
422423
423424 if response .status_code < 300 :
424425 return Archive (self , response .json ())
@@ -447,7 +448,7 @@ def get_archives(self, offset=None, count=None):
447448 if count is not None :
448449 params ['count' ] = count
449450
450- response = requests .get (self .archive_url () + "?" + urlencode (params ), headers = self .archive_headers (), proxies = self .proxies )
451+ response = requests .get (self .archive_url () + "?" + urlencode (params ), headers = self .archive_headers (), proxies = self .proxies , timeout = self . timeout )
451452
452453 if response .status_code < 300 :
453454 return ArchiveList (self , response .json ())
0 commit comments