本文整理汇总了Python中http.client.ResponseNotReady方法的典型用法代码示例。如果您正苦于以下问题:Python client.ResponseNotReady方法的具体用法?Python client.ResponseNotReady怎么用?Python client.ResponseNotReady使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http.client
的用法示例。
在下文中一共展示了client.ResponseNotReady方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _download_file
# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import ResponseNotReady [as 别名]
def _download_file(self, proxy, subtitle_ids):
"""
Tries to download byte data. If successful the data will be stored to a table in the database. Afterwards, that
same data will be taken from that table and another table and written to a file.
"""
download_data = dict()
try:
download_data = proxy.DownloadSubtitles(self.opensubs_token, subtitle_ids)
except ProtocolError as e:
download_data["status"] = e
self.prompt_label.setText("There has been a ProtocolError during downloading")
except ResponseNotReady as e:
download_data["status"] = e
self.prompt_label.setText("There has been a ResponseNotReady Error during downloading")
if download_data["status"] == "200 OK":
self._store_byte_data_to_db(download_data)
self._get_stored_byte_data()
else:
self.prompt_label.setText("There was an error while trying to download your file: {}"
.format(download_data["status"]))
示例2: __init__
# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import ResponseNotReady [as 别名]
def __init__(self):
httplib2.RETRIES = 1
self.MAX_RETRIES = 10
self.RETRIABLE_EXCEPTIONS = (httplib2.HttpLib2Error, IOError, httplib.NotConnected,
httplib.IncompleteRead, httplib.ImproperConnectionState,
httplib.CannotSendRequest, httplib.CannotSendHeader,
httplib.ResponseNotReady, httplib.BadStatusLine)
self.RETRIABLE_STATUS_CODES = [500, 502, 503, 504]
self.CLIENT_SECRETS_FILE = "client_secrets.json"
self.YOUTUBE_UPLOAD_SCOPE = "https://www.googleapis.com/auth/youtube.upload"
self.YOUTUBE_API_SERVICE_NAME = "youtube"
self.YOUTUBE_API_VERSION = "v3"
self.MISSING_CLIENT_SECRETS_MESSAGE = """
WARNING: Please configure OAuth 2.0
To make this sample run you will need to populate the client_secrets.json file
found at:
%s
with information from the Developers Console
https://console.developers.google.com/
For more information about the client_secrets.json file format, please visit:
https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
""" % os.path.abspath(os.path.join(os.path.dirname(__file__),
self.CLIENT_SECRETS_FILE))
示例3: test_request_handler_with_http_response_not_ready_error
# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import ResponseNotReady [as 别名]
def test_request_handler_with_http_response_not_ready_error(self):
managed_object = 'VirtualMachine'
def side_effect(mo, **kwargs):
self.assertEqual(managed_object, mo._type)
self.assertEqual(managed_object, mo.value)
raise httplib.ResponseNotReady()
svc_obj = service.Service()
attr_name = 'powerOn'
service_mock = svc_obj.client.service
setattr(service_mock, attr_name, side_effect)
self.assertRaises(exceptions.VimSessionOverLoadException,
svc_obj.powerOn,
managed_object)
示例4: _prefetch_in_background
# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import ResponseNotReady [as 别名]
def _prefetch_in_background(self, n, amount, offset):
headers = {
'Range': "bytes=" + str(max(offset, 0)) + "-" + str(
min((offset + amount) - 1, self.length) # noqa
),
}
self._wait_on_prefetch_connection(n)
while not self.pconn_terminated[n]:
try:
self.pconn[n].request(
"GET", self.parsed_url.path, headers=headers)
break
except CannotSendRequest:
sleep(1)
while not self.pconn_terminated[n]:
try:
res = self.pconn[n].getresponse()
break
except ResponseNotReady:
# Since we are sharing the connection wait for this to be
# ready
sleep(1)
if self.pconn_terminated[n]:
self._unwait_on_prefetch_connection(n)
return
else:
self._unwait_on_prefetch_connection(n)
if not(res.status >= 200 and res.status <= 299):
# Check for a valid status from the server
return
data = bytearray(res.length)
i = 0
for piece in iter(lambda: res.read(1024), bytes('')):
if not getattr(threading.currentThread(), "do_run", True):
break
data[i:i + len(piece)] = piece
i = i + len(piece)
else:
return bytes(data)
# Leaving the thread early, without
# reading all of the data this will
# make the connection unusable, refresh it
self._prepare_prefetch_connection(n)