Python http.client.ResponseNotReady() Examples
The following are 5
code examples of http.client.ResponseNotReady().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
http.client
, or try the search function
.
Example #1
Source File: subtitles.py From SubCrawl with MIT License | 6 votes |
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"]))
Example #2
Source File: uploadrobot.py From youtube-video-maker with GNU General Public License v3.0 | 5 votes |
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))
Example #3
Source File: test_service.py From oslo.vmware with Apache License 2.0 | 5 votes |
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)
Example #4
Source File: __init__.py From magnitude with MIT License | 4 votes |
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)
Example #5
Source File: __init__.py From supersqlite with MIT License | 4 votes |
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)