Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

default.py 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # -*- test-case-name: twisted.internet.test.test_default -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. The most suitable default reactor for the current platform.
  6. Depending on a specific application's needs, some other reactor may in
  7. fact be better.
  8. """
  9. __all__ = ["install"]
  10. from twisted.python.runtime import platform
  11. def _getInstallFunction(platform):
  12. """
  13. Return a function to install the reactor most suited for the given platform.
  14. @param platform: The platform for which to select a reactor.
  15. @type platform: L{twisted.python.runtime.Platform}
  16. @return: A zero-argument callable which will install the selected
  17. reactor.
  18. """
  19. # Linux: epoll(7) is the default, since it scales well.
  20. #
  21. # macOS: poll(2) is not exposed by Python because it doesn't support all
  22. # file descriptors (in particular, lack of PTY support is a problem) --
  23. # see <http://bugs.python.org/issue5154>. kqueue has the same restrictions
  24. # as poll(2) as far PTY support goes.
  25. #
  26. # Windows: IOCP should eventually be default, but still has some serious
  27. # bugs, e.g. <http://twistedmatrix.com/trac/ticket/4667>.
  28. #
  29. # We therefore choose epoll(7) on Linux, poll(2) on other non-macOS POSIX
  30. # platforms, and select(2) everywhere else.
  31. try:
  32. if platform.isLinux():
  33. try:
  34. from twisted.internet.epollreactor import install
  35. except ImportError:
  36. from twisted.internet.pollreactor import install
  37. elif platform.getType() == "posix" and not platform.isMacOSX():
  38. from twisted.internet.pollreactor import install
  39. else:
  40. from twisted.internet.selectreactor import install
  41. except ImportError:
  42. from twisted.internet.selectreactor import install
  43. return install
  44. install = _getInstallFunction(platform)