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