disable ThreadingTCPServer dns revsere lookup, sometimes it will be slow
This commit is contained in:
parent
5d34ac2fa8
commit
449673c875
2 changed files with 9 additions and 3 deletions
7
local.py
7
local.py
|
@ -34,6 +34,9 @@ import threading
|
||||||
import time
|
import time
|
||||||
import SocketServer
|
import SocketServer
|
||||||
|
|
||||||
|
#disable ThreadingTCPServer dns revsere lookup, sometimes it will be slow
|
||||||
|
socket.getfqdn = lambda x:x
|
||||||
|
|
||||||
def socket_create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
def socket_create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
||||||
source_address=None):
|
source_address=None):
|
||||||
"""python 2.7 socket.create_connection"""
|
"""python 2.7 socket.create_connection"""
|
||||||
|
@ -51,14 +54,14 @@ def socket_create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
||||||
sock.connect(sa)
|
sock.connect(sa)
|
||||||
return sock
|
return sock
|
||||||
|
|
||||||
except socket.error as _:
|
except error as _:
|
||||||
err = _
|
err = _
|
||||||
if sock is not None:
|
if sock is not None:
|
||||||
sock.close()
|
sock.close()
|
||||||
if err is not None:
|
if err is not None:
|
||||||
raise err
|
raise err
|
||||||
else:
|
else:
|
||||||
raise error("getaddrinfo returns an empty list")
|
raise socket.error("getaddrinfo returns an empty list")
|
||||||
|
|
||||||
def get_table(key):
|
def get_table(key):
|
||||||
m = hashlib.md5()
|
m = hashlib.md5()
|
||||||
|
|
|
@ -37,6 +37,9 @@ import string
|
||||||
import hashlib
|
import hashlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
#disable ThreadingTCPServer dns revsere lookup, sometimes it will be slow
|
||||||
|
socket.getfqdn = lambda x:x
|
||||||
|
|
||||||
def socket_create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
def socket_create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
||||||
source_address=None):
|
source_address=None):
|
||||||
"""python 2.7 socket.create_connection"""
|
"""python 2.7 socket.create_connection"""
|
||||||
|
@ -61,7 +64,7 @@ def socket_create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
||||||
if err is not None:
|
if err is not None:
|
||||||
raise err
|
raise err
|
||||||
else:
|
else:
|
||||||
raise error("getaddrinfo returns an empty list")
|
raise socket.error("getaddrinfo returns an empty list")
|
||||||
|
|
||||||
def get_table(key):
|
def get_table(key):
|
||||||
m = hashlib.md5()
|
m = hashlib.md5()
|
||||||
|
|
Loading…
Reference in a new issue