# Find the best reactor
selectWarning = "Unable to install any good reactors (kqueue, epoll, poll).\nWe fell back to using select. You may have scalability problems.\nThis reactor will not support more than 1024 connections at a time."
-try:
- from twisted.internet import epollreactor as bestreactor
-except:
- #try:
- #from twisted.internet import kqreactor as bestreactor
- #except:
+reactors = [("epollreactor", True), ("pollreactor", True), ("selectreactor", False), ("default", False)]
+for tryReactor, good in reactors:
try:
- from twisted.internet import pollreactor as bestreactor
- except:
- try:
- from twisted.internet import selectreactor as bestreactor
- print selectWarning
- except:
- try:
- from twisted.internet import default as bestreactor
- print selectWarning
- except:
- print "Unable to find a reactor. Please make sure you have Twisted properly installed.\nExiting..."
- sys.exit(1)
-bestreactor.install()
+ bestReactor = __import__("twisted.internet." + tryReactor)
+ if not good:
+ print >> sys.stderr, selectWarning
+ break
+ except ImportError:
+ pass
+else:
+ print >> sys.stderr, "Unable to find a reactor. Please make sure you have Twisted properly installed.\nExiting..."
+ sys.exit(1)
+
import twistfix
twistfix.main()
from twisted.internet import kqreactor
kqreactor.install()
elif len(config.reactor) > 0:
- print "Unknown reactor: ", config.reactor, ". Using select(), reactor."
+ print >> sys.stderr, "Unknown reactor: ", config.reactor, ". Using best available reactor."
from twisted.internet import reactor, task