Opened 16 years ago

Closed 14 years ago

#1485 defect closed fixed (fixed)

Calling reactor.stop() in shutdown function causes hard-to-understand error message

Reported by: itamarst Owned by:
Priority: high Milestone:
Component: core Keywords:
Cc: itamarst, Thijs Triemstra Branch:
Author:

Description


Change History (4)

comment:1 Changed 16 years ago by itamarst

Specifically, if the shutdown function returns a Deferred, and some later code
calls reactor.stop(). Ideally it should say something like "don't do that."

comment:2 Changed 15 years ago by therve

I think that is more or less solved. See the following script:

from twisted.internet import reactor

if __name__ == "__main__":
    reactor.addSystemEventTrigger('after', 'shutdown', reactor.stop)
    reactor.callLater(0.5, reactor.stop)
    reactor.run()

which produces the following output:

Traceback (most recent call last):
  File "/home/th/twisted_dev/twisted/trunk/twisted/internet/base.py", line 376, in fireEvent
    DeferredList(beforeResults).addCallback(self._continueFiring)
  File "/home/th/twisted_dev/twisted/trunk/twisted/internet/defer.py", line 191, in addCallback
    callbackKeywords=kw)
  File "/home/th/twisted_dev/twisted/trunk/twisted/internet/defer.py", line 182, in addCallbacks
    self._runCallbacks()
  File "/home/th/twisted_dev/twisted/trunk/twisted/internet/defer.py", line 317, in _runCallbacks
    self.result = callback(self.result, *args, **kw)
--- <exception caught here> ---
  File "/home/th/twisted_dev/twisted/trunk/twisted/internet/base.py", line 389, in _continueFiring
    callable(*args, **kwargs)
  File "/home/th/twisted_dev/twisted/trunk/twisted/internet/base.py", line 480, in stop
    raise RuntimeError, "can't stop reactor that isn't running"
exceptions.RuntimeError: can't stop reactor that isn't running

At least, the error is more clear.

comment:3 Changed 14 years ago by Thijs Triemstra

Cc: Thijs Triemstra added
Resolution: fixed
Status: newclosed

And nowadays it looks like:

Traceback (most recent call last):
  File "/twisted/internet/base.py", line 374, in fireEvent
    DeferredList(beforeResults).addCallback(self._continueFiring)
  File "/twisted/internet/defer.py", line 195, in addCallback
    callbackKeywords=kw)
  File "/twisted/internet/defer.py", line 186, in addCallbacks
    self._runCallbacks()
  File "/twisted/internet/defer.py", line 328, in _runCallbacks
    self.result = callback(self.result, *args, **kw)
--- <exception caught here> ---
  File "/twisted/internet/base.py", line 387, in _continueFiring
    callable(*args, **kwargs)
  File "/twisted/internet/base.py", line 527, in stop
    "Can't stop reactor that isn't running.")
twisted.internet.error.ReactorNotRunning: Can't stop reactor that isn't running.

Closing this ticket because it doesn't describe the text of the error message, making it impossible to verify if it was fixed or not. Reopen with a more detailed description if necessary.

comment:4 Changed 11 years ago by <automation>

Note: See TracTickets for help on using tickets.