Opened 6 years ago

Closed 6 years ago

#3168 regression closed fixed (fixed)

ClientFactory.clientConnectionFailed re-entrancy problem

Reported by: exarkun Owned by:
Priority: highest Milestone:
Component: core Keywords:
Cc: Branch:
Author: Launchpad Bug:

Description

Consider:

from twisted.internet import protocol, reactor

class Stopper(protocol.ClientFactory):
    def clientConnectionFailed(self, connector, reason):
        print 'here'
        reactor.stop()


def main():
    reactor.connectTCP("localhost", 12345, Stopper())
    reactor.run()

if __name__ == '__main__':
    main()

With Twisted 2.5.0, this results in here being printed once and the process exiting. With Twisted 8.0.1, this is the result:

here
here
Traceback (most recent call last):
  File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/defer.py", line 186, in addCallbacks
    self._runCallbacks()
  File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/defer.py", line 328, in _runCallbacks
    self.result = callback(self.result, *args, **kw)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/base.py", line 387, in _continueFiring
    callable(*args, **kwargs)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/base.py", line 524, in disconnectAll
    failure.Failure(main.CONNECTION_LOST))
--- <exception caught here> ---
  File "/home/exarkun/Projects/Twisted/trunk/twisted/python/log.py", line 51, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/python/log.py", line 36, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/python/context.py", line 59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/python/context.py", line 37, in callWithContext
    return func(*args,**kw)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/tcp.py", line 574, in connectionLost
    self.failIfNotConnected(error.ConnectError(string=reason))
  File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/tcp.py", line 479, in failIfNotConnected
    self.connector.connectionFailed(failure.Failure(err))
  File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/base.py", line 929, in connectionFailed
    self.factory.clientConnectionFailed(self, reason)
  File "foo.py", line 6, in clientConnectionFailed
    reactor.stop()
  File "/home/exarkun/Projects/Twisted/trunk/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.

Change History (6)

comment:1 Changed 6 years ago by exarkun

This seems to have roughly the same origin as #3146

comment:2 Changed 6 years ago by exarkun

(In [23273]) Perhaps a test for #3168

refs #3168

comment:3 Changed 6 years ago by exarkun

  • Keywords review added
  • Owner glyph deleted
  • Priority changed from high to highest

See #3146.

comment:4 Changed 6 years ago by exarkun

(In [23342]) Refer to another ticket

refs #3168
refs #3146
refs #3198

comment:5 Changed 6 years ago by exarkun

  • Keywords review removed
  • Resolution set to fixed
  • Status changed from new to closed

This was resolved r23345

comment:6 Changed 3 years ago by <automation>

Note: See TracTickets for help on using tickets.