当前位置: 首页>>代码示例>>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;未经允许,请勿转载。