Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3680 defect closed wontfix (wontfix)

Reactor stop claims reactor not running when both a callLater and a StandardIO are active

Reported by: bhyde Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


bash-3.2$ (sleep 2; date +%s; sleep 2; date +%s ; sleep 10) | /tmp/
Traceback (most recent call last):
  File "/opt/local/lib/python2.5/site-packages/twisted/python/", line 59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/opt/local/lib/python2.5/site-packages/twisted/python/", line 37, in callWithContext
    return func(*args,**kw)
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/", line 258, in connectionLost
    self.proc.childConnectionLost(, reason)
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/", line 86, in childConnectionLost
--- <exception caught here> ---
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/", line 105, in connectionLost
  File "/tmp/", line 9, in connectionLost
    def connectionLost(self, why): reactor.stop()
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/", line 490, in stop
    "Can't stop reactor that isn't running.")
twisted.internet.error.ReactorNotRunning: Can't stop reactor that isn't running.
bash-3.2$ cat /tmp/
#!/usr/bin/env python
from twisted.internet import reactor
from twisted.protocols.basic import LineOnlyReceiver
from twisted.internet.stdio import StandardIO

class MyLineOnlyReceiver(LineOnlyReceiver):
    delimiter = '\n'
    def lineReceived(self, line): print line
    def connectionLost(self, why): reactor.stop()

if __name__ == '__main__':
    def finish():
        print 'done'
    reactor.callLater(10, finish) 
bash-3.2$ port info 'py25-twisted'
py25-twisted @8.0.1 (python, devel, net)

Twisted is an event-driven networking framework written in Python. Twisted supports TCP,
UDP, SSL/TLS, multicast, Unix sockets, a large number of protocols (including HTTP, NNTP,
SSH, IRC, FTP, and others), and much more.

Library Dependencies: python25, py25-zopeinterface
bash-3.2$ python -V
Python 2.5.4
bash-3.2$ uname -a
Darwin 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 i386

Change History (3)

comment:1 Changed 13 years ago by Jean-Paul Calderone

Resolution: wontfix
Status: newclosed

The example code calls reactor.stop() twice. First in finish, then later in MyLineOnlyReceiver.connectionLost. The second call to reactor.stop() is the one that fails, because indeed the reactor is already shutting down.

comment:2 Changed 13 years ago by bhyde

Sweet. Thanks. I'm an idiot.

comment:3 Changed 11 years ago by <automation>

Owner: Glyph deleted
Note: See TracTickets for help on using tickets.