Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def continue_connect (self, answer = None):
self.initialize_connection ()
if not adns.query:
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
try: asynchat.async_chat.connect (self, self.address)
except: self.handle_error (714)
return
ipaddr = answer [-1]["data"]
#print (self.handler.request.meta ['sid'], ipaddr, 'continue_connect...')
if not ipaddr:
return self.handle_close (704)
else:
port = self.address [1]
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
try:
asynchat.async_chat.connect (self, (ipaddr, port))
except:
self.handle_error (714)
if not adns.query:
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
try: asynchat.async_chat.connect (self, self.address)
except: self.handle_error (714)
return
ipaddr = answer [-1]["data"]
#print (self.handler.request.meta ['sid'], ipaddr, 'continue_connect...')
if not ipaddr:
return self.handle_close (704)
else:
port = self.address [1]
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
try:
asynchat.async_chat.connect (self, (ipaddr, port))
except:
self.handle_error (714)
from rs4 import asynchat
import socket
import time
from .pydns import Base, Type, Class, Lib, Opcode
class UDPClient (asynchat.async_chat):
protocol = "udp"
zombie_timeout = 1200
ac_in_buffer_size = 512
def __init__ (self, addr, logger):
self.addr = addr
self.logger = logger
self.event_time = time.time ()
self.creation_time = time.time ()
self.closed = False
self._timeouted = False
self.requests = {}
self.callback = None
asynchat.async_chat.__init__ (self)
def query (self, request, args, callback):
if __name__ == '__main__':
import time
def thread_function (output_file, i, n):
print('entering thread_function')
while n:
time.sleep (5)
output_file.write ('%2d.%2d %s\r\n' % (i, n, output_file))
output_file.flush()
n = n - 1
output_file.close()
print('exiting thread_function')
class thread_parent (asynchat.async_chat):
def __init__ (self, conn, addr):
self.addr = addr
asynchat.async_chat.__init__ (self, conn)
self.set_terminator (b'\r\n')
self.buffer = ''
self.count = 0
def collect_incoming_data (self, data):
self.buffer = self.buffer + data
def found_terminator (self):
data, self.buffer = self.buffer, ''
if not data:
asyncore.close_all()
print("done")
from rs4 import asynchat
from . import dbconnect
import socket
DEBUG = True
LINE_FEED = b"\r\n"
class RedisError (Exception):
pass
class AsynConnect (dbconnect.AsynDBConnect, asynchat.async_chat):
def __init__ (self, address, params = None, lock = None, logger = None):
dbconnect.AsynDBConnect.__init__ (self, address, params, lock, logger)
asynchat.async_chat.__init__ (self)
def close (self, deactive = 1):
asynchat.async_chat.close (self)
# re-init asychat
self.ac_in_buffer = b''
self.incoming = []
self.producer_fifo.clear()
dbconnect.AsynDBConnect.close (self, deactive)
self.logger ("[info] ..dbo %s:%d has been closed" % self.address)
def handle_connect (self):
self.set_event_time ()