Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteccac33

Browse files
committed
add optional timeout parameter
Used to specify a timeout (in seconds) after the connect operationshould be aborted. This is to prevent the client from hangingindefinitely in some connection error cases.
1 parent04ada3b commiteccac33

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

‎zencoder/core.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class HTTPBackend(object):
3131
3232
@FIXME: Build in support for supplying arbitrary backends
3333
"""
34-
def__init__(self,api_key,as_xml=False,resource_name=None):
34+
def__init__(self,api_key,as_xml=False,resource_name=None,timeout=None):
3535
"""
3636
Creates an HTTPBackend object, which abstracts out some of the
3737
library specific HTTP stuff.
@@ -41,7 +41,7 @@ def __init__(self, api_key, as_xml=False, resource_name=None):
4141
self.base_url=self.base_url+resource_name
4242

4343
#TODO investigate httplib2 caching and if it is necessary
44-
self.http=httplib2.Http()
44+
self.http=httplib2.Http(timeout=timeout)
4545
self.as_xml=as_xml
4646
self.api_key=api_key
4747

@@ -122,7 +122,7 @@ def process(self, http_response, content):
122122

123123
classZencoder(object):
124124
""" This is the entry point to the Zencoder API """
125-
def__init__(self,api_key=None,as_xml=False):
125+
def__init__(self,api_key=None,as_xml=False,timeout=None):
126126
"""
127127
Initializes Zencoder. You must have a valid API_KEY.
128128
@@ -142,9 +142,9 @@ def __init__(self, api_key=None, as_xml=False):
142142
self.api_key=api_key
143143

144144
self.as_xml=as_xml
145-
self.job=Job(self.api_key,self.as_xml)
146-
self.account=Account(self.api_key,self.as_xml)
147-
self.output=Output(self.api_key,self.as_xml)
145+
self.job=Job(self.api_key,self.as_xml,timeout=timeout)
146+
self.account=Account(self.api_key,self.as_xml,timeout=timeout)
147+
self.output=Output(self.api_key,self.as_xml,timeout=timeout)
148148

149149
classResponse(object):
150150
"""
@@ -159,11 +159,11 @@ def __init__(self, code, body, raw_body, raw_response):
159159

160160
classAccount(HTTPBackend):
161161
""" Account object """
162-
def__init__(self,api_key=None,as_xml=False):
162+
def__init__(self,api_key=None,as_xml=False,timeout=None):
163163
"""
164164
Initializes an Account object
165165
"""
166-
super(Account,self).__init__(api_key,as_xml,'account')
166+
super(Account,self).__init__(api_key,as_xml,'account',timeout=timeout)
167167

168168
defcreate(self,email,tos=True,options=None):
169169
"""
@@ -204,11 +204,11 @@ def live(self):
204204

205205
classOutput(HTTPBackend):
206206
""" Gets information regarding outputs """
207-
def__init__(self,api_key,as_xml=False):
207+
def__init__(self,api_key,as_xml=False,timeout=None):
208208
"""
209209
Contains all API methods relating to Outputs.
210210
"""
211-
super(Output,self).__init__(api_key,as_xml,'outputs')
211+
super(Output,self).__init__(api_key,as_xml,'outputs',timeout=timeout)
212212

213213
defprogress(self,output_id):
214214
"""
@@ -222,11 +222,11 @@ class Job(HTTPBackend):
222222
"""
223223
Contains all API methods relating to transcoding Jobs.
224224
"""
225-
def__init__(self,api_key,as_xml=False):
225+
def__init__(self,api_key,as_xml=False,timeout=None):
226226
"""
227227
Initialize a job object
228228
"""
229-
super(Job,self).__init__(api_key,as_xml,'jobs')
229+
super(Job,self).__init__(api_key,as_xml,'jobs',timeout=timeout)
230230

231231
defcreate(self,input,outputs=None,options=None):
232232
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp