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


Python urllib3.contrib方法代碼示例

本文整理匯總了Python中urllib3.contrib方法的典型用法代碼示例。如果您正苦於以下問題:Python urllib3.contrib方法的具體用法?Python urllib3.contrib怎麽用?Python urllib3.contrib使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urllib3的用法示例。


在下文中一共展示了urllib3.contrib方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: close

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import contrib [as 別名]
def close(self):
        """
        Closes the event streaming.
        """

        if not self._response.raw.closed:
            # find the underlying socket object
            # based on api.client._get_raw_response_socket

            sock_fp = self._response.raw._fp.fp

            if hasattr(sock_fp, 'raw'):
                sock_raw = sock_fp.raw

                if hasattr(sock_raw, 'sock'):
                    sock = sock_raw.sock

                elif hasattr(sock_raw, '_sock'):
                    sock = sock_raw._sock

            elif hasattr(sock_fp, 'channel'):
                # We're working with a paramiko (SSH) channel, which doesn't
                # support cancelable streams with the current implementation
                raise DockerException(
                    'Cancellable streams not supported for the SSH protocol'
                )
            else:
                sock = sock_fp._sock

            if hasattr(urllib3.contrib, 'pyopenssl') and isinstance(
                    sock, urllib3.contrib.pyopenssl.WrappedSocket):
                sock = sock.socket

            sock.shutdown(socket.SHUT_RDWR)
            sock.close() 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:37,代碼來源:daemon.py

示例2: _get_http_client

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import contrib [as 別名]
def _get_http_client():
    # don't use the AppEngineManager when sockets access is enabled
    # see https://urllib3.readthedocs.io/en/latest/reference/urllib3.contrib.html#module-urllib3.contrib.appengine
    if appengine.is_appengine_sandbox() and 'GAE_USE_SOCKETS_HTTPLIB' not in os.environ:
        return appengine.AppEngineManager()
    return urllib3.PoolManager() 
開發者ID:cloudendpoints,項目名稱:endpoints-management-python,代碼行數:8,代碼來源:service_config.py


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