Skip to content
Browse files

Revert r35841 - the example is broken and diverges from the coding st…

…andard

Reopens: #5951


git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@35872 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information...
1 parent b2b9819 commit 0acfbb476639c3b9525fbac801c36e4d0a73e79a exarkun committed
Showing with 8 additions and 31 deletions.
  1. +8 −31 twisted/internet/reactor.py
  2. 0 twisted/news/topfiles/5951.misc
View
39 twisted/internet/reactor.py
@@ -8,37 +8,14 @@
The default reactor depends on the platform and will be installed if this
module is imported without another reactor being explicitly installed
-beforehand.
-
-Importing this module will get a reference to whichever reactor is installed.
-However, the recommended way to get references to the reactor is to pass and
-accept the reactor as a parameter where it is needed, and to import the
-reactor only at the root of the application. This simplifies unit testing and
-may make it easier to one day support multiple reactors (as a performance
-enhancement), though this is not currently possible.
-
-For example, if the library code is::
-
- def do_something_later(*args, reactor=None, **kwargs):
- reactor.callLater(5, do_something, *args, **kwargs)
-
-And the application or plugin code has something like::
-
- def makeService(options):
- import reactor
- ...
- do_something_later("something", reactor=reactor)
-
-Then the `do_something_later` function can be tested by passing a
-L{IReactorTime<twisted.internet.interfaces.IReactorTime>} provider (see
-L{twisted.internet.task.Clock}). If the library code imported
-the reactor instead of accepting it as an argument, then the reactor may need
-to be monkey-patched with a mocked version when tested.
-
-Also, imported the reactor in fewer places makes it easier to debug "reactor
-already installed" errors, which can happen for example if `twistd` is run
-with a specified reactor, and the application code imports the reactor
-too early.
+beforehand. Regardless of which reactor is installed, importing this module is
+the correct way to get a reference to it.
+
+New application code should prefer to pass and accept the reactor as a
+parameter where it is needed, rather than relying on being able to import this
+module to get a reference. This simplifies unit testing and may make it easier
+to one day support multiple reactors (as a performance enhancement), though
+this is not currently possible.
@see: L{IReactorCore<twisted.internet.interfaces.IReactorCore>}
@see: L{IReactorTime<twisted.internet.interfaces.IReactorTime>}
View
0 twisted/news/topfiles/5951.misc
No changes.

0 comments on commit 0acfbb4

Please sign in to comment.
Something went wrong with that request. Please try again.