예제 #1
0
    def listen(self, listen_sock, data_event):
        """creates and starts a data thread on the listen_sock
        
        **INPUTS**
        
        socket *listen_sock* -- The listen socket

        **OUTPUTS**
        
        *MixedMessenger* -- a MixedMessenger for the listen socket, which 
        sends messages via an underlying MessengerBasic, but receives them 
        from a Queue.
        """

        data_thread = self.new_data_thread_given_event(listen_sock, data_event)
        self.data_thread = data_thread
        messages = data_thread.message_queue()
        data_thread.setDaemon(1)
        data_thread.start()

        listen_response_msgr = messaging.messenger_factory(listen_sock,
                                                           sleep=0.05)
        listen_msgr = messaging.MixedMessenger(listen_response_msgr, messages)

        return listen_msgr
예제 #2
0
    def listen(self, listen_sock, data_event):
        """creates and starts a data thread on the listen_sock
        
        **INPUTS**
        
        socket *listen_sock* -- The listen socket

        **OUTPUTS**
        
        *MixedMessenger* -- a MixedMessenger for the listen socket, which 
        sends messages via an underlying MessengerBasic, but receives them 
        from a Queue.
        """
        
        data_thread = self.new_data_thread_given_event(listen_sock,
            data_event)
        self.data_thread = data_thread
        messages = data_thread.message_queue()
        data_thread.setDaemon(1)
        data_thread.start()

        listen_response_msgr = messaging.messenger_factory(listen_sock, 
            sleep = messenger_sleep_time)        
        listen_msgr = messaging.MixedMessenger(listen_response_msgr, messages)
 
        return listen_msgr
예제 #3
0
    def new_data_thread_given_event(self, listen_sock, data_event):
        """creates a new ListenAndQueueMsgsThread to monitor the
        listen_sock
        
        **INPUTS**

        SocketHasDataEvent *data_event* -- the SocketHasDataEvent event
        to pass to the new thread

        STR *ID* -- The unique ID of the listen socket
        
        socket *listen_sock* -- The listen socket
        
        **OUTPUTS**
        
        [ListenAndQueueMsgsThread] -- the new threading.Thread object

        ..[ListenAndQueueMsgsThread] 
        file:///./tcp_server.ListenAndQueueMsgsThread.html"""
        queue = Queue.Queue()
        broken_connection = ('broken_connection', {})
        self.client_quitting = threading.Event()
        sleeper = messaging.LightSleeper(self.client_quitting)
        a_msgr = messaging.messenger_factory(listen_sock,
                                             sleep=0.05,
                                             sleeper=sleeper)
        thread = ListenAndQueueMsgsThread(a_msgr, queue, data_event,
                                          self.client_quitting,
                                          broken_connection)
        return thread
예제 #4
0
    def new_data_thread_given_event(self, listen_sock, data_event):
        """creates a new ListenAndQueueMsgsThread to monitor the
        listen_sock
        
        **INPUTS**

        SocketHasDataEvent *data_event* -- the SocketHasDataEvent event
        to pass to the new thread

        STR *ID* -- The unique ID of the listen socket
        
        socket *listen_sock* -- The listen socket
        
        **OUTPUTS**
        
        [ListenAndQueueMsgsThread] -- the new threading.Thread object

        ..[ListenAndQueueMsgsThread] 
        file:///./tcp_server.ListenAndQueueMsgsThread.html"""        
        queue = Queue.Queue()
        broken_connection = ('broken_connection', {})
        self.client_quitting = threading.Event()
        sleeper = messaging.LightSleeper(self.client_quitting)
        a_msgr = messaging.messenger_factory(listen_sock, sleep = messenger_sleep_time,
            sleeper = sleeper)
        thread = ListenAndQueueMsgsThread(a_msgr, queue, data_event,
           self.client_quitting, broken_connection)
        return thread