Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def abort(self):
print(self.host, "=>", "failed")
def close(self):
print(self.host, "=>")
print(self.text)
#
# try it out
for host in []:
consumer = WhoisConsumer(host)
request = WhoisRequest(consumer, host, "whois.internic.net")
# loop returns when all requests have been processed
asyncore.loop()
meta ['req_id'] = _que.req_id
meta ['req_method'] = method
meta ['req_callback'] = callback
_que.add ((method, url, params, auth, headers, meta, proxy))
# DNS query for caching and massive
if not lifetime._polling and _dns_reqs < _workers:
host = urlparse (url) [1].split (":")[0]
if host not in _dns_query_req:
_dns_query_req [host] = None
_dns_reqs += 1
adns.query (host, "A", callback = lambda x: None)
if dns.qsize ():
dns.pop_all ()
asyncore.loop (0.1, count = 2)
#print ('~~~~~~~~~~~~~~~', asyndns.pool.connections)
def __init__ (self, family=socket.AF_INET, address=('', 9003)):
asyncore.dispatcher.__init__ (self)
self.create_socket (family, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind (address)
self.listen (5)
def handle_accept (self):
conn, addr = self.accept()
tp = thread_parent (conn, addr)
thread_server()
#asyncore.loop(1.0, use_poll=1)
try:
asyncore.loop ()
except:
asyncore.close_all()
self.handler.handle_request (name, **args)
if (not count and not self.has_job ()):
return
map = {}
with self.lock:
for client in self.udps:
map [client._fileno] = client
fds = list (map.keys ())
# maybe 2 is enough
safeguard = count * 2
while self.has_job () and safeguard:
safeguard -= 1
asyncore.loop (0.1, map, count = 1)
if safeguard % 5 == 0:
self.maintern (time.time ())
self.maintern (time.time ())
for fd in fds:
if fd not in map:
# resync
try: del asyncore.socket_map [fd]
except KeyError: pass
#query ("www.alexa.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.yahoo.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.github.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.google.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.amazon.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.almec.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.alamobeauty.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.alphaworld.com", protocol = "udp", callback = _print, qtype="a")
#query ("www.allrightsales.com", protocol = "udp", callback = _print, qtype="a")
query ("www.glasteel.com", protocol = "udp", callback = _print, qtype="a")
pop_all ()
print ('------------------------')
while 1:
pop_all ()
asyncore.loop (timeout = 1, count = 1)
print ('UNFINISHED', pool.jobs ())