[Twisted-Python] Newbie question - simpleclient.py crashes

Hi all, I have just started looking at Twisted. I thought I would start by working my way through the examples. The first one I tried crashed on me! I can patch it to get it to work, but I would rather learn the exact reason for the crash, and the correct way to fix it. I am trying to run simpleserver.py and simpleclient.py, using RH9, Python 2.4.1, and Twisted 2.1.0. I start simpleserver from tty1, and then from tty2 I run simpleclient. This is the result (shortened) - Server said: hello, world! connection lost Connection lost - goodbye! Traceback: [...] File '.../twisted/internet/base.py', line 398, in _continueSystemEvent for callList in sysEvtTriggers[1], sysEvtTriggers[2]: exceptions.TypeError: unsubscriptable object AFAICT, this is what is happening. simpleclient calls reactor.stop() from a number of places, but for this exercise it calls it twice - once from EchoClient.connectionLost(), once from EchoFactory.clientConnectionLost(). The first time, base._continueSystemEvent() is called with eventType "shutdown". It handles the event, then deletes "shutdown" from self._eventTriggers. When it is called the second time, also with eventType "shutdown", it cannot find the event type as it has been deleted, so it crashes with the above traceback. I changed simpleclient.EchoClient.connectionLost() so that it does not call reactor.stop(), and the program runs without errors. Is this the correct solution? Why do the Protocol and the Factory both have a connectionLost method? Which one should call reactor.stop()? Thanks. Frank Millman

On Sun, 30 Oct 2005 09:50:31 +0200, Frank Millman <frank@chagford.com> wrote:
Hi all,
Hi Frank!
I believe you have spotted a rather serious bug. Can you add this to the tracker <http://www.twistedmatrix.com/bugs> for further discussion and fixing? Thanks!

On Sun, 30 Oct 2005 09:50:31 +0200, Frank Millman <frank@chagford.com> wrote:
Hi all,
Hi Frank!
I believe you have spotted a rather serious bug. Can you add this to the tracker <http://www.twistedmatrix.com/bugs> for further discussion and fixing? Thanks!
participants (2)
-
Frank Millman
-
glyph@divmod.com