TCP4ClientEndpoint.connect's deferred cannot be cancelled successfully
|Reported by:||marienz||Owned by:||Glyph|
branch-diff, diff-cov, branch-cov, buildbot
If you try to cancel the deferred returned from TCP4ClientEndpoint before it has connected the following happens:
- the _canceller function in t.i.endpoints calls connector.stopConnecting()
- this ends up calling connector.connectionFailed()
- connectionFailed calls factory.clientConnectionFailed
- factory is the endpoints._WrappingFactory, whose clientConnectionFailed errbacks its deferred (the same deferred we are cancelling)
- the canceller then tries to errback its deferred with a ConnectingCancelledError, which triggers AlreadyCalledError
test_endpoints misses this because the MemoryReactor's _FakeConnector's stopConnecting does not do anything (so it does not hit the factory's clientConnectionFailed).
Attached is a pretty terrible testcase demonstrating this, which fails for me with an AlreadyCalledError on twisted 10.1.0 and trunk.
Change History (15)
comment:11 follow-up: 12 Changed 5 years ago by
|Owner:||changed from Jean-Paul Calderone to Glyph|
|Status:||assigned → new|