id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,branch,branch_author,launchpad_bug
3270,The XMPP example in Twisted.Words crashes if I stop it with Ctrl-C,jozilla,exarkun,"The XMPP example (xmpp_client.py) in Twisted words throws an exception when I quit it with Ctrl-C:

{{{
Disconnected.
Traceback (most recent call last):
  File ""/usr/lib/python2.5/site-packages/twisted/internet/posixbase.py"", line 228, in mainLoop
    self.runUntilCurrent()
  File ""/usr/lib/python2.5/site-packages/twisted/internet/base.py"", line 561, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File ""/usr/lib/python2.5/site-packages/twisted/internet/base.py"", line 414, in _continueSystemEvent
    callable(*args, **kw)
  File ""/usr/lib/python2.5/site-packages/twisted/internet/base.py"", line 375, in disconnectAll
    failure.Failure(main.CONNECTION_LOST))
--- <exception caught here> ---
  File ""/usr/lib/python2.5/site-packages/twisted/python/log.py"", line 48, in callWithLogger
    return callWithContext({""system"": lp}, func, *args, **kw)
  File ""/usr/lib/python2.5/site-packages/twisted/python/log.py"", line 33, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File ""/usr/lib/python2.5/site-packages/twisted/python/context.py"", line 59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File ""/usr/lib/python2.5/site-packages/twisted/python/context.py"", line 37, in callWithContext
    return func(*args,**kw)
  File ""/usr/lib/python2.5/site-packages/twisted/internet/tcp.py"", line 576, in connectionLost
    Connection.connectionLost(self, reason)
  File ""/usr/lib/python2.5/site-packages/twisted/internet/tcp.py"", line 416, in connectionLost
    protocol.connectionLost(reason)
  File ""/usr/lib/python2.5/site-packages/twisted/words/xish/xmlstream.py"", line 82, in connectionLost
    self.dispatch(self, STREAM_END_EVENT)
  File ""/usr/lib/python2.5/site-packages/twisted/words/xish/utility.py"", line 227, in dispatch
    self._eventObservers[(priority, event)].callback(object)
  File ""/usr/lib/python2.5/site-packages/twisted/words/xish/utility.py"", line 37, in callback
    methodwrapper(*args, **kwargs)
  File ""/usr/lib/python2.5/site-packages/twisted/words/xish/utility.py"", line 21, in __call__
    self.method(*nargs, **nkwargs)
  File ""xmpp_client.py"", line 58, in disconnected
    reactor.stop()
  File ""/usr/lib/python2.5/site-packages/twisted/internet/base.py"", line 342, in stop
    raise RuntimeError, ""can't stop reactor that isn't running""
exceptions.RuntimeError: can't stop reactor that isn't running
}}}

I already posted this on the mailing list. Here is the comment by Ralph Meijer:

=================
I haven't seen that behavior before, but I can confirm this happens. I
poked around a bit with the example. It seems that the socket is closed
before its factory is shut down. It might be that the reactor shutdown
procedure has changed, so I think this behavior is the result of a bug,
either in the example or somewhere else. 
=================",defect,closed,normal,,words,fixed,,,branches/xmpp_client.py-3270-3,exarkun,
