[Twisted-Python] Reactor questions
Clark C. Evans
cce at clarkevans.com
Thu Apr 3 09:53:54 MST 2003
On Thu, Apr 03, 2003 at 10:18:52AM -0500, Itamar Shtull-Trauring wrote:
| On Thu, 3 Apr 2003 00:54:25 -0800 (PST)
| Jasper Phillips <jasper at peak.org> wrote:
|
| > I notice from expirmentation that reactor.stop() seems to sever any
| > ongoing network connections. Is there a way to temporarily stop then
| > restart the reactor without losing a network connection? Or would I
| > need to write my own reactor?
| >
| > I'm writing unit tests, where I want to script a sequence of events.
| > Currently I have a (pyui) loop calling
| > twisted.internet.main.iterate(), and have my code accept a startup
| > flag telling it whether to stop for procederal
|
| 1. Never ever use twisted.internet.main. Please. It is waaaay
| deprecated.
|
| 2. You can use reactor.iterate().
|
| 3. For unittesting, reactor.crash() does exactly what you want - stop
| reactor without closing anything.
In my unit tests I often do the following.
reactor.callLater(2, reactor.stop)
Just before the reactor starts.
Clark
More information about the Twisted-Python
mailing list