Opened 6 years ago

Closed 6 years ago

Last modified 6 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:
Author: Launchpad Bug:

Description

bash-3.2$ (sleep 2; date +%s; sleep 2; date +%s ; sleep 10) | /tmp/bar.py
1236440028
1236440030
done
Traceback (most recent call last):
  File "/opt/local/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/opt/local/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext
    return func(*args,**kw)
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/process.py", line 258, in connectionLost
    self.proc.childConnectionLost(self.name, reason)
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/_posixstdio.py", line 86, in childConnectionLost
    self.connectionLost(reason)
--- <exception caught here> ---
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/_posixstdio.py", line 105, in connectionLost
    protocol.connectionLost(reason)
  File "/tmp/bar.py", line 9, in connectionLost
    def connectionLost(self, why): reactor.stop()
  File "/opt/local/lib/python2.5/site-packages/twisted/internet/base.py", 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/bar.py
#!/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__':
    StandardIO(MyLineOnlyReceiver())
    def finish():
        print 'done'
        reactor.stop()
    reactor.callLater(10, finish)
    reactor.run() 
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.
Homepage:    http://www.twistedmatrix.com/

Library Dependencies: python25, py25-zopeinterface
Maintainers:          stechert@macports.org akitada@macports.org
                      openmaintainer@macports.org
bash-3.2$ python -V
Python 2.5.4
bash-3.2$ uname -a
Darwin d72.cozy.org 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
bash-3.2$ 

Change History (3)

comment:1 Changed 6 years ago by exarkun

  • Resolution set to wontfix
  • Status changed from new to closed

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 6 years ago by bhyde

Sweet. Thanks. I'm an idiot.

comment:3 Changed 4 years ago by <automation>

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