demntor / pymodbus

Modbus Python release (tools included)
0 stars 0 forks source link

Helper method to install best reactor #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Maybe have a helper method to install the best reactor for the system:

#--------------------------------------------------------------------------
-# 
# Helper Methods
#--------------------------------------------------------------------------
-# 
def install_specialized_reactor():
    ''' 
    This attempts to install a reactor specialized for the given
    operating system.

    :returns: True if a specialized reactor was installed, False otherwise
    '''
    from twisted.internet import epollreactor, kqreactor, iocpreactor
    for reactor in [epollreactor, kqreactor, iocpreactor]:
        try:
            reactor.install()
            _logger.debug("Installed %s" % reactor.__name__)
            return True
        except: pass
    _logger.debug("No specialized reactor was installed")
    return False

Original issue reported on code.google.com by Bashw...@gmail.com on 4 Jun 2010 at 7:38

GoogleCodeExporter commented 8 years ago

Original comment by Bashw...@gmail.com on 4 Jan 2011 at 8:01