def writemessage(self, text): """Put data in output queue, rebuild the prompt and entered data""" # Need to grab the input queue lock to ensure the entered data doesn't change # before we're done rebuilding it. # Note that writemessage will eventually call writecooked self.IQUEUELOCK.acquire() TelnetHandlerBase.writemessage(self, text) self.IQUEUELOCK.release()
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a greenlet to handle socket input self.greenlet_ic = gevent.spawn(self.inputcooker) # Note that inputcooker exits on EOF # Sleep for 0.5 second to allow options negotiation gevent.sleep(0.5)
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a greenlet to handle socket input self.greenlet_ic = eventlet.spawn(self.inputcooker) # Note that inputcooker exits on EOF # Sleep for 0.5 second to allow options negotiation eventlet.sleep(0.5)
def __init__(self, request, client_address, server): # This is the cooked input stream (list of charcodes) self.cookedq = [] # Create the locks for handing the input/output queues self.IQUEUELOCK = threading.Lock() self.OQUEUELOCK = threading.Lock() # Call the base class init method TelnetHandlerBase.__init__(self, request, client_address, server)
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a thread to handle socket input self.thread_ic = threading.Thread(target=self.inputcooker) self.thread_ic.setDaemon(True) self.thread_ic.start() # Note that inputcooker exits on EOF # Sleep for 0.5 second to allow options negotiation time.sleep(0.5)
def writecooked(self, text): """Put data directly into the output queue""" # Ensure this is the only thread writing self.OQUEUELOCK.acquire() TelnetHandlerBase.writecooked(self, text) self.OQUEUELOCK.release()
def finish(self): '''Called as the session is ending''' TelnetHandlerBase.finish(self)
def finish(self): '''Called as the session is ending''' TelnetHandlerBase.finish(self) # Ensure the greenlet is dead gevent.kill(self.greenlet_ic)
def __init__(self, request, client_address, server): # Create a green queue for input handling self.cookedq = gevent.queue.Queue() # Call the base class init method TelnetHandlerBase.__init__(self, request, client_address, server)
def __init__(self, request, client_address, server): # Create a green queue for input handling self.cookedq = eventlet.queue.Queue() # Call the base class init method TelnetHandlerBase.__init__(self, request, client_address, server)
def finish(self): '''Called as the session is ending''' TelnetHandlerBase.finish(self) # Ensure the greenlet is dead self.greenlet_ic.kill()