@@ -59,10 +59,11 @@ class OpenTok(object):
59
59
TOKEN_SENTINEL = 'T1=='
60
60
"""For internal use."""
61
61
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 ):
63
63
self .api_key = str (api_key )
64
64
self .api_secret = api_secret
65
65
self .api_url = api_url
66
+ self .timeout = timeout
66
67
self ._proxies = None
67
68
68
69
@property
@@ -263,7 +264,7 @@ def create_session(self, location=None, media_mode=MediaModes.relayed, archive_m
263
264
options [u ('location' )] = location
264
265
265
266
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 )
267
268
response .encoding = 'utf-8'
268
269
269
270
if response .status_code == 403 :
@@ -351,7 +352,7 @@ def start_archive(self, session_id, has_audio=True, has_video=True, name=None, o
351
352
'outputMode' : output_mode .value
352
353
}
353
354
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 )
355
356
356
357
if response .status_code < 300 :
357
358
return Archive (self , response .json ())
@@ -377,7 +378,7 @@ def stop_archive(self, archive_id):
377
378
378
379
:rtype: The Archive object corresponding to the archive being stopped.
379
380
"""
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 )
381
382
382
383
if response .status_code < 300 :
383
384
return Archive (self , response .json ())
@@ -400,7 +401,7 @@ def delete_archive(self, archive_id):
400
401
401
402
:param String archive_id: The archive ID of the archive to be deleted.
402
403
"""
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 )
404
405
405
406
if response .status_code < 300 :
406
407
pass
@@ -418,7 +419,7 @@ def get_archive(self, archive_id):
418
419
419
420
:rtype: The Archive object.
420
421
"""
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 )
422
423
423
424
if response .status_code < 300 :
424
425
return Archive (self , response .json ())
@@ -447,7 +448,7 @@ def get_archives(self, offset=None, count=None):
447
448
if count is not None :
448
449
params ['count' ] = count
449
450
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 )
451
452
452
453
if response .status_code < 300 :
453
454
return ArchiveList (self , response .json ())
0 commit comments