diff options
author | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:16:14 +0300 |
---|---|---|
committer | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:43:30 +0300 |
commit | b8cf9e88f4c5c64d9406af533d8948deb050d695 (patch) | |
tree | 218eb61fb3c3b96ec08b4d8cdfef383104a87d63 /contrib/python/Twisted/py2/twisted/internet/default.py | |
parent | 523f645a83a0ec97a0332dbc3863bb354c92a328 (diff) | |
download | ydb-b8cf9e88f4c5c64d9406af533d8948deb050d695.tar.gz |
add kikimr_configure
Diffstat (limited to 'contrib/python/Twisted/py2/twisted/internet/default.py')
-rw-r--r-- | contrib/python/Twisted/py2/twisted/internet/default.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/contrib/python/Twisted/py2/twisted/internet/default.py b/contrib/python/Twisted/py2/twisted/internet/default.py new file mode 100644 index 0000000000..c78fb18520 --- /dev/null +++ b/contrib/python/Twisted/py2/twisted/internet/default.py @@ -0,0 +1,56 @@ +# -*- test-case-name: twisted.internet.test.test_default -*- +# Copyright (c) Twisted Matrix Laboratories. +# See LICENSE for details. + +""" +The most suitable default reactor for the current platform. + +Depending on a specific application's needs, some other reactor may in +fact be better. +""" + +from __future__ import division, absolute_import + +__all__ = ["install"] + +from twisted.python.runtime import platform + + +def _getInstallFunction(platform): + """ + Return a function to install the reactor most suited for the given platform. + + @param platform: The platform for which to select a reactor. + @type platform: L{twisted.python.runtime.Platform} + + @return: A zero-argument callable which will install the selected + reactor. + """ + # Linux: epoll(7) is the default, since it scales well. + # + # macOS: poll(2) is not exposed by Python because it doesn't support all + # file descriptors (in particular, lack of PTY support is a problem) -- + # see <http://bugs.python.org/issue5154>. kqueue has the same restrictions + # as poll(2) as far PTY support goes. + # + # Windows: IOCP should eventually be default, but still has some serious + # bugs, e.g. <http://twistedmatrix.com/trac/ticket/4667>. + # + # We therefore choose epoll(7) on Linux, poll(2) on other non-macOS POSIX + # platforms, and select(2) everywhere else. + try: + if platform.isLinux(): + try: + from twisted.internet.epollreactor import install + except ImportError: + from twisted.internet.pollreactor import install + elif platform.getType() == 'posix' and not platform.isMacOSX(): + from twisted.internet.pollreactor import install + else: + from twisted.internet.selectreactor import install + except ImportError: + from twisted.internet.selectreactor import install + return install + + +install = _getInstallFunction(platform) |