id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,branch,branch_author,launchpad_bug
4710,TCP4ClientEndpoint.connect's deferred cannot be cancelled successfully,marienz,glyph,"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.",defect,closed,high,,core,fixed,,glyph,branches/endpoint-cancel-4710,glyph,
