#6104 enhancement new
Make it possible to cancel getPage and downloadPage
|Reported by:||luks||Owned by:||luks|
(github, patch, buildbot, log)
Currently there is no way to cancel the deferreds returned by getPage or downloadPage. The attached patch adds a canceller to these deferreds, so calling d.cancel() will actually close the connection and fail with CancelledError. The implementation is similar to twisted.web.xmlrpc.Proxy.callRemote, with a different way of calling the errback.
I had to change HTTPClientFactory.clientConnectionFailed, because even though the docstring suggests it should be possible to send a result to the deferred before this method is called, it wouldn't fire _disconnectedDeferred in that case and the user-specified callback/errback would never be actually called.