main.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- test-case-name: twisted.internet.test.test_main -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. Backwards compatibility, and utility functions.
  6. In general, this module should not be used, other than by reactor authors
  7. who need to use the 'installReactor' method.
  8. """
  9. from __future__ import division, absolute_import
  10. from twisted.internet import error
  11. CONNECTION_DONE = error.ConnectionDone('Connection done')
  12. CONNECTION_LOST = error.ConnectionLost('Connection lost')
  13. def installReactor(reactor):
  14. """
  15. Install reactor C{reactor}.
  16. @param reactor: An object that provides one or more IReactor* interfaces.
  17. """
  18. # this stuff should be common to all reactors.
  19. import twisted.internet
  20. import sys
  21. if 'twisted.internet.reactor' in sys.modules:
  22. raise error.ReactorAlreadyInstalledError("reactor already installed")
  23. twisted.internet.reactor = reactor
  24. sys.modules['twisted.internet.reactor'] = reactor
  25. __all__ = ["CONNECTION_LOST", "CONNECTION_DONE", "installReactor"]