[Twisted-Python] Reactor questions

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 input after remote PB calls. This is a bit awkward, and so I'm hoping someone has dealt with this before in twisted. - -Jasper -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE+i/bG8EpjZ7/X9bIRAg3GAJ90/aobSqyYGy+NgKbDyZYbS/+TNQCgs6sy yOxkTjygUV5T5jUiBCNzBHw= =B+J1 -----END PGP SIGNATURE-----

On Thu, 3 Apr 2003 00:54:25 -0800 (PST) Jasper Phillips <jasper@peak.org> wrote:
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. -- Itamar Shtull-Trauring http://itamarst.org/ http://www.zoteca.com -- Python & Twisted consulting

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@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

On Thu, 3 Apr 2003 16:53:54 +0000 "Clark C. Evans" <cce@clarkevans.com> wrote:
reactor.crash is better for tests since you can call reactor.run again afterwards. -- Itamar Shtull-Trauring http://itamarst.org/ http://www.zoteca.com -- Python & Twisted consulting

On Thu, 3 Apr 2003, Itamar Shtull-Trauring wrote:
Yah, I saw a note to that effect in main, but I was following an example I found, and the results worked so I stuck with it for a bit.
2. You can use reactor.iterate().
Much better.
3. For unittesting, reactor.crash() does exactly what you want - stop reactor without closing anything.
Ah, I see it now. The name threw me off, as "crash" doesn't exactly sound recoverable. ;-) Thanks for your help! -Jasper

On Thu, 3 Apr 2003 00:54:25 -0800 (PST) Jasper Phillips <jasper@peak.org> wrote:
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. -- Itamar Shtull-Trauring http://itamarst.org/ http://www.zoteca.com -- Python & Twisted consulting

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@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

On Thu, 3 Apr 2003 16:53:54 +0000 "Clark C. Evans" <cce@clarkevans.com> wrote:
reactor.crash is better for tests since you can call reactor.run again afterwards. -- Itamar Shtull-Trauring http://itamarst.org/ http://www.zoteca.com -- Python & Twisted consulting

On Thu, 3 Apr 2003, Itamar Shtull-Trauring wrote:
Yah, I saw a note to that effect in main, but I was following an example I found, and the results worked so I stuck with it for a bit.
2. You can use reactor.iterate().
Much better.
3. For unittesting, reactor.crash() does exactly what you want - stop reactor without closing anything.
Ah, I see it now. The name threw me off, as "crash" doesn't exactly sound recoverable. ;-) Thanks for your help! -Jasper
participants (3)
-
Clark C. Evans
-
Itamar Shtull-Trauring
-
Jasper Phillips