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


Python socket._GLOBAL_DEFAULT_TIMEOUT屬性代碼示例

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


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

示例1: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(self, host, port=None, strict=None,
                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
        self.timeout = timeout
        self.source_address = source_address
        self.sock = None
        self._buffer = []
        self.__response = None
        self.__state = _CS_IDLE
        self._method = None
        self._tunnel_host = None
        self._tunnel_port = None
        self._tunnel_headers = {}
        if strict is not None:
            self.strict = strict

        (self.host, self.port) = self._get_hostport(host, port)

        # This is stored as an instance variable to allow unittests
        # to replace with a suitable mock
        self._create_connection = socket.create_connection 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:22,代碼來源:httplib.py

示例2: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(self, host, port=None, strict=_strict_sentinel,
                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
        if strict is not _strict_sentinel:
            warnings.warn("the 'strict' argument isn't supported anymore; "
                "http.client now always assumes HTTP/1.x compliant servers.",
                DeprecationWarning, 2)
        self.timeout = timeout
        self.source_address = source_address
        self.sock = None
        self._buffer = []
        self.__response = None
        self.__state = _CS_IDLE
        self._method = None
        self._tunnel_host = None
        self._tunnel_port = None
        self._tunnel_headers = {}

        self._set_hostport(host, port) 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:20,代碼來源:client.py

示例3: urlopen

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, **_3to2kwargs):
    if 'cadefault' in _3to2kwargs: cadefault = _3to2kwargs['cadefault']; del _3to2kwargs['cadefault']
    else: cadefault = False
    if 'capath' in _3to2kwargs: capath = _3to2kwargs['capath']; del _3to2kwargs['capath']
    else: capath = None
    if 'cafile' in _3to2kwargs: cafile = _3to2kwargs['cafile']; del _3to2kwargs['cafile']
    else: cafile = None
    global _opener
    if cafile or capath or cadefault:
        if not _have_ssl:
            raise ValueError('SSL support not available')
        context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
        context.options |= ssl.OP_NO_SSLv2
        context.verify_mode = ssl.CERT_REQUIRED
        if cafile or capath:
            context.load_verify_locations(cafile, capath)
        else:
            context.set_default_verify_paths()
        https_handler = HTTPSHandler(context=context, check_hostname=True)
        opener = build_opener(https_handler)
    elif _opener is None:
        _opener = opener = build_opener()
    else:
        opener = _opener
    return opener.open(url, data, timeout) 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:27,代碼來源:request.py

示例4: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(
        self,
        host,
        port=None,
        key_file=None,
        cert_file=None,
        key_password=None,
        strict=None,
        timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
        ssl_context=None,
        server_hostname=None,
        **kw
    ):

        HTTPConnection.__init__(self, host, port, strict=strict, timeout=timeout, **kw)

        self.key_file = key_file
        self.cert_file = cert_file
        self.key_password = key_password
        self.ssl_context = ssl_context
        self.server_hostname = server_hostname

        # Required property for Google AppEngine 1.9.0 which otherwise causes
        # HTTPS requests to go out as HTTP. (See Issue #356)
        self._protocol = "https" 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:27,代碼來源:connection.py

示例5: _urlopen

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def _urlopen(url, data=None,
                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                 cafile=None, capath=None, cadefault=False,
                 context=None):

        def http_response(request, response):
            return response

        http_error_processor = HTTPErrorProcessor()
        http_error_processor.https_response = http_response

        if context:
            https_handler = HTTPSHandler(context=context)
            opener = build_opener(https_handler, http_error_processor)
        else:
            opener = build_opener(http_error_processor)

        return opener.open(url, data, timeout) 
開發者ID:PaloAltoNetworks,項目名稱:terraform-templates,代碼行數:20,代碼來源:wfapi.py

示例6: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(self, host, port=None, strict=None,
                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
        self.timeout = timeout
        self.source_address = source_address
        self.sock = None
        self._buffer = []
        self.__response = None
        self.__state = _CS_IDLE
        self._method = None
        self._tunnel_host = None
        self._tunnel_port = None
        self._tunnel_headers = {}

        self._set_hostport(host, port)
        if strict is not None:
            self.strict = strict 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:18,代碼來源:httplib.py

示例7: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(self, host=None, port=0,
                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
        """Constructor.

        When called without arguments, create an unconnected instance.
        With a hostname argument, it connects the instance; port number
        and timeout are optional.
        """
        self.debuglevel = DEBUGLEVEL
        self.host = host
        self.port = port
        self.timeout = timeout
        self.sock = None
        self.rawq = ''
        self.irawq = 0
        self.cookedq = ''
        self.eof = 0
        self.iacseq = '' # Buffer for IAC sequence.
        self.sb = 0 # flag for SB and SE sequence.
        self.sbdataq = ''
        self.option_callback = None
        if host is not None:
            self.open(host, port, timeout) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:25,代碼來源:telnetlib.py

示例8: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(self, host, port=None, strict=None,
                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
        self.timeout = timeout
        self.source_address = source_address
        self.sock = None
        self._buffer = []
        self.__response = None
        self.__state = _CS_IDLE
        self._method = None
        self._tunnel_host = None
        self._tunnel_port = None
        self._tunnel_headers = {}
        if strict is not None:
            self.strict = strict

        (self.host, self.port) = self._get_hostport(host, port)

        self._validate_host(self.host)

        # This is stored as an instance variable to allow unittests
        # to replace with a suitable mock
        self._create_connection = socket.create_connection 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:24,代碼來源:httplib.py

示例9: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(self, host, port=None, key_file=None, cert_file=None,
                 strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, **kw):

        HTTPConnection.__init__(self, host, port, strict=strict,
                                timeout=timeout, **kw)

        self.key_file = key_file
        self.cert_file = cert_file

        # Required property for Google AppEngine 1.9.0 which otherwise causes
        # HTTPS requests to go out as HTTP. (See Issue #356)
        self._protocol = 'https' 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:14,代碼來源:connection.py

示例10: clone

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def clone(self):
        """ Create a copy of the timeout object

        Timeout properties are stored per-pool but each request needs a fresh
        Timeout object to ensure each one has its own start/stop configured.

        :return: a copy of the timeout object
        :rtype: :class:`Timeout`
        """
        # We can't use copy.deepcopy because that will also create a new object
        # for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to
        # detect the user default.
        return Timeout(connect=self._connect, read=self._read,
                       total=self.total) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:16,代碼來源:timeout.py

示例11: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def __init__(self, host, port=None, key_file=None, cert_file=None,
                 strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                 ssl_context=None, server_hostname=None, **kw):

        HTTPConnection.__init__(self, host, port, strict=strict,
                                timeout=timeout, **kw)

        self.key_file = key_file
        self.cert_file = cert_file
        self.ssl_context = ssl_context
        self.server_hostname = server_hostname

        # Required property for Google AppEngine 1.9.0 which otherwise causes
        # HTTPS requests to go out as HTTP. (See Issue #356)
        self._protocol = 'https' 
開發者ID:danielecook,項目名稱:gist-alfred,代碼行數:17,代碼來源:connection.py

示例12: create_connection

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
                      source_address=None):
    """Backport of 3-argument create_connection() for Py2.6.

    Connect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    """

    host, port = address
    err = None
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
        af, socktype, proto, canonname, sa = res
        sock = None
        try:
            sock = socket(af, socktype, proto)
            if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
                sock.settimeout(timeout)
            if source_address:
                sock.bind(source_address)
            sock.connect(sa)
            return sock

        except error as _:
            err = _
            if sock is not None:
                sock.close()

    if err is not None:
        raise err
    else:
        raise error("getaddrinfo returns an empty list")

# Backport from Py2.7 for Py2.6: 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:43,代碼來源:misc.py

示例13: create_connection

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
                      source_address=None):
    """Connect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    """

    host, port = address
    err = None
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
        af, socktype, proto, canonname, sa = res
        sock = None
        try:
            sock = socket(af, socktype, proto)
            if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
                sock.settimeout(timeout)
            if source_address:
                sock.bind(source_address)
            sock.connect(sa)
            return sock

        except error as _:
            err = _
            if sock is not None:
                sock.close()

    if err is not None:
        raise err
    else:
        raise error("getaddrinfo returns an empty list") 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:39,代碼來源:socket.py

示例14: clone

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def clone(self):
        """ Create a copy of the timeout object

        Timeout properties are stored per-pool but each request needs a fresh
        Timeout object to ensure each one has its own start/stop configured.

        :return: a copy of the timeout object
        :rtype: :class:`Timeout`
        """
        # We can't use copy.deepcopy because that will also create a new object
        # for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to
        # detect the user default.
        return Timeout(connect=self._connect, read=self._read, total=self.total) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:15,代碼來源:timeout.py

示例15: has_timeout

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import _GLOBAL_DEFAULT_TIMEOUT [as 別名]
def has_timeout(timeout):
    if hasattr(socket, "_GLOBAL_DEFAULT_TIMEOUT"):
        return timeout is not None and timeout is not socket._GLOBAL_DEFAULT_TIMEOUT
    return timeout is not None 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:6,代碼來源:__init__.py


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