reactor.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. The reactor is the Twisted event loop within Twisted, the loop which drives
  5. applications using Twisted. The reactor provides APIs for networking,
  6. threading, dispatching events, and more.
  7. The default reactor depends on the platform and will be installed if this
  8. module is imported without another reactor being explicitly installed
  9. beforehand. Regardless of which reactor is installed, importing this module is
  10. the correct way to get a reference to it.
  11. New application code should prefer to pass and accept the reactor as a
  12. parameter where it is needed, rather than relying on being able to import this
  13. module to get a reference. This simplifies unit testing and may make it easier
  14. to one day support multiple reactors (as a performance enhancement), though
  15. this is not currently possible.
  16. @see: L{IReactorCore<twisted.internet.interfaces.IReactorCore>}
  17. @see: L{IReactorTime<twisted.internet.interfaces.IReactorTime>}
  18. @see: L{IReactorProcess<twisted.internet.interfaces.IReactorProcess>}
  19. @see: L{IReactorTCP<twisted.internet.interfaces.IReactorTCP>}
  20. @see: L{IReactorSSL<twisted.internet.interfaces.IReactorSSL>}
  21. @see: L{IReactorUDP<twisted.internet.interfaces.IReactorUDP>}
  22. @see: L{IReactorMulticast<twisted.internet.interfaces.IReactorMulticast>}
  23. @see: L{IReactorUNIX<twisted.internet.interfaces.IReactorUNIX>}
  24. @see: L{IReactorUNIXDatagram<twisted.internet.interfaces.IReactorUNIXDatagram>}
  25. @see: L{IReactorFDSet<twisted.internet.interfaces.IReactorFDSet>}
  26. @see: L{IReactorThreads<twisted.internet.interfaces.IReactorThreads>}
  27. @see: L{IReactorPluggableResolver<twisted.internet.interfaces.IReactorPluggableResolver>}
  28. """
  29. import sys
  30. del sys.modules["twisted.internet.reactor"]
  31. from twisted.internet import default
  32. default.install()