id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	branch	branch_author	launchpad_bug
4153	It should be easier to choose a sane reactor default for a given platform	ericflo		"I recently needed the functionality to choose an epoll reactor on Linux, kqueue reactor on bsd, poll reactor on unixes, and select reactor on windows.  I looked around a bit in the source and was surprised to find that there was no functionality for doing this easily.  I wrote a simple function to do this, and popped on the ''#twisted'' IRC channel, where '''spiv''' suggested that I open a ticket about this for discussion.

Below is my quickly-written function:

{{{
def installCommonReactor():
    try:
        from twisted.internet import kqreactor
        kqreactor.install()
        return
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        pass
    try:
        from twisted.internet import epollreactor
        epollreactor.install()
        return
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        pass
    try:
        from twisted.internet import pollreactor
        pollreactor.install()
        return
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        pass
}}}

Notes about this particular implementation: I did it in this way of repeated imports for maximum explicitness.  I could envision, however, trading some of that explicitness for flexibility (you could supply a priority list, loop over the list, and dynamically import the reactors that way).  Also, I'm not extremely happy with the exception whitelisting, as ImportError would be far and away the most common exception.  That being said, I can foresee other errors as well and since this is really about falling back to what reactor works in a given environment, that was the reasoning behind that detail.

Questions: Is this something Twisted is interesting in incorporating at all? What are the thoughts on what an implementation would look like?"	enhancement	closed	normal		core	duplicate					
