1 # -*- test-case-name: twisted.internet.test.test_default -*-
2 # Copyright (c) Twisted Matrix Laboratories.
3 # See LICENSE for details.
6 The most suitable default reactor for the current platform.
8 Depending on a specific application's needs, some other reactor may in
14 from twisted.python.runtime import platform
17 def _getInstallFunction(platform):
19 Return a function to install the reactor most suited for the given platform.
21 @param platform: The platform for which to select a reactor.
22 @type platform: L{twisted.python.runtime.Platform}
24 @return: A zero-argument callable which will install the selected
27 # Linux: epoll(7) is the fault, since it scales well.
29 # OS X: poll(2) is not exposed by Python because it doesn't
30 # support all file descriptors (in particular, lack of PTY support
31 # is a problem) -- see <http://bugs.python.org/issue5154>. kqueue
32 # reactor is being rewritten (see
33 # <http://twistedmatrix.com/trac/ticket/1918>), and also has same
34 # restriction as poll(2) as far PTY support goes.
36 # Windows: IOCP should eventually be default, but still has some serious
37 # bugs, e.g. <http://twistedmatrix.com/trac/ticket/4667>.
39 # We therefore choose epoll(7) on Linux, poll(2) on other non-OS X POSIX
40 # platforms, and select(2) everywhere else.
42 if platform.isLinux():
44 from twisted.internet.epollreactor import install
46 from twisted.internet.pollreactor import install
47 elif platform.getType() == 'posix' and not platform.isMacOSX():
48 from twisted.internet.pollreactor import install
50 from twisted.internet.selectreactor import install
52 from twisted.internet.selectreactor import install
56 install = _getInstallFunction(platform)