refactoring
This commit is contained in:
@@ -143,7 +143,7 @@ def create_connection(url, timeout=None, **options):
|
|||||||
websock = WebSocket(sockopt=sockopt, sslopt=sslopt,
|
websock = WebSocket(sockopt=sockopt, sslopt=sslopt,
|
||||||
fire_cont_frame = fire_cont_frame, enable_multithread=enable_multithread,
|
fire_cont_frame = fire_cont_frame, enable_multithread=enable_multithread,
|
||||||
skip_utf8_validation=skip_utf8_validation)
|
skip_utf8_validation=skip_utf8_validation)
|
||||||
websock.settimeout(timeout if timeout is not None else default_timeout)
|
websock.settimeout(timeout if timeout is not None else getdefaulttimeout())
|
||||||
websock.connect(url, **options)
|
websock.connect(url, **options)
|
||||||
return websock
|
return websock
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ if hasattr(socket, "TCP_KEEPINTVL"):
|
|||||||
if hasattr(socket, "TCP_KEEPCNT"):
|
if hasattr(socket, "TCP_KEEPCNT"):
|
||||||
DEFAULT_SOCKET_OPTION.append((socket.SOL_TCP, socket.TCP_KEEPCNT, 3))
|
DEFAULT_SOCKET_OPTION.append((socket.SOL_TCP, socket.TCP_KEEPCNT, 3))
|
||||||
|
|
||||||
default_timeout = None
|
_default_timeout = None
|
||||||
|
|
||||||
def setdefaulttimeout(timeout):
|
def setdefaulttimeout(timeout):
|
||||||
"""
|
"""
|
||||||
@@ -44,15 +44,15 @@ def setdefaulttimeout(timeout):
|
|||||||
|
|
||||||
timeout: default socket timeout time. This value is second.
|
timeout: default socket timeout time. This value is second.
|
||||||
"""
|
"""
|
||||||
global default_timeout
|
global _default_timeout
|
||||||
default_timeout = timeout
|
_default_timeout = timeout
|
||||||
|
|
||||||
|
|
||||||
def getdefaulttimeout():
|
def getdefaulttimeout():
|
||||||
"""
|
"""
|
||||||
Return the global timeout setting(second) to connect.
|
Return the global timeout setting(second) to connect.
|
||||||
"""
|
"""
|
||||||
return default_timeout
|
return _default_timeout
|
||||||
|
|
||||||
|
|
||||||
def recv(sock, bufsize):
|
def recv(sock, bufsize):
|
||||||
|
Reference in New Issue
Block a user