Ejemplo n.º 1
0
 def run(self):
     """
     Main TCP receive loop. Should be run in a separate thread -- use start()
     to do this automatically.
     """
     self.is_shutdown = False
     if not self.server_sock:
         raise ROSInternalException("%s did not connect"%self.__class__.__name__)
     while not self.is_shutdown:
         try:
             (client_sock, client_addr) = self.server_sock.accept()
         except socket.timeout:
             continue
         except ConnectionAbortedError:
             continue
         except IOError as e:
             (e_errno, msg, *_) = e.args
             if e_errno == errno.EINTR: #interrupted system call
                 continue
             if not self.is_shutdown:
                 raise
         if self.is_shutdown:
             break
         try:
             #leave threading decisions up to inbound_handler
             self.inbound_handler(client_sock, client_addr)
         except socket.error as e:
             if not self.is_shutdown:
                 traceback.print_exc()
                 logwarn("Failed to handle inbound connection due to socket error: %s"%e)
     logdebug("TCPServer[%s] shutting down", self.port)
Ejemplo n.º 2
0
 def run(self):
     """
     Main TCP receive loop. Should be run in a separate thread -- use start()
     to do this automatically.
     """
     self.is_shutdown = False
     if not self.server_sock:
         raise ROSInternalException("%s did not connect" %
                                    self.__class__.__name__)
     while not self.is_shutdown:
         try:
             (client_sock, client_addr) = self.server_sock.accept()
         except socket.timeout:
             continue
         if self.is_shutdown:
             break
         try:
             #leave threading decisions up to inbound_handler
             self.inbound_handler(client_sock, client_addr)
         except socket.error, e:
             if not self.is_shutdown:
                 traceback.print_exc()
                 logwarn(
                     "Failed to handle inbound connection due to socket error: %s"
                     % e)