How to use the rs4.asyncore.loop function in rs4

To help you get started, we’ve selected a few rs4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hansroh / aquests / aquests / protocols / whois.py View on Github external
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()
github hansroh / aquests / aquests / __init__.py View on Github external
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)
github hansroh / aquests / aquests / athreads / select_trigger.py View on Github external
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()
github hansroh / aquests / aquests / protocols / dns / __init__.py View on Github external
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
github hansroh / aquests / aquests / protocols / dns / __init__.py View on Github external
#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 ())