ljean / modbus-tk

Create Modbus app easily with Python
Other
568 stars 213 forks source link

Server should return when it fails to run Server._do_init. #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When a TcpServer fails to bound to a socket (because it is already in use or 
user hasn't proper permissions) the TcpServer hangs. 

The TcpServer hangs because the `_do_init()` method is called within a 
try/catch all statement.

        try:         
            self._do_init()                                                                   
            while self._go.isSet():                                              
                self._do_run()                                                      
            LOGGER.info("%s has stopped" % self.__class__)                       
            self._do_exit()                                                      
        except Exception, excpt:                                                 
            LOGGER.error("server error: %s" % str(excpt))                        
        self._make_thread() #make possible to rerun in future           

I think that the call to `self_do_init()` should be done outside try/catch 
block. These exception must boil up to caller. 

Original issue reported on code.google.com by AWooster...@gmail.com on 28 Feb 2015 at 7:50

ljean commented 9 years ago

fixed