Exemple #1
0
 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()
Exemple #2
0
    def setup(self):
        TelnetHandlerBase.setup(self)
        # Spawn a greenlet to handle socket input
        self.greenlet_ic = gevent.spawn(wrap_errors((socket.error), self.inputcooker))
        # Note that inputcooker exits on EOF

        # Sleep for 0.5 second to allow options negotiation
        gevent.sleep(0.5)
Exemple #3
0
    def setup(self):
        TelnetHandlerBase.setup(self)
        # Spawn a greenlet to handle socket input
        self.greenlet_ic = gevent.spawn(
            wrap_errors((socket.error), self.inputcooker))
        # Note that inputcooker exits on EOF

        # Sleep for 0.5 second to allow options negotiation
        gevent.sleep(0.5)
Exemple #4
0
    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)
Exemple #5
0
    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)
Exemple #6
0
    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)
Exemple #7
0
 def finish(self):
     """Called as the session is ending"""
     TelnetHandlerBase.finish(self)
     # Ensure the greenlet is dead
     self.greenlet_ic.kill()
Exemple #8
0
 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)
Exemple #9
0
 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()
Exemple #10
0
 def finish(self):
     '''Called as the session is ending'''
     TelnetHandlerBase.finish(self)