當前位置: 首頁>>代碼示例>>Python>>正文


Python client.ResponseNotReady方法代碼示例

本文整理匯總了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"])) 
開發者ID:lukaabra,項目名稱:SubCrawl,代碼行數:23,代碼來源:subtitles.py

示例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)) 
開發者ID:crhenr,項目名稱:youtube-video-maker,代碼行數:32,代碼來源:uploadrobot.py

示例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) 
開發者ID:openstack,項目名稱:oslo.vmware,代碼行數:17,代碼來源:test_service.py

示例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) 
開發者ID:plasticityai,項目名稱:magnitude,代碼行數:48,代碼來源:__init__.py


注:本文中的http.client.ResponseNotReady方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。