本文整理匯總了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()
示例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()