-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST with TLS causes double-close on body producer #185
Comments
Still happening in Twisted v17.9.0 and treq v17.8.0 |
(Thanks @horkhe for the ping) |
My 2c., Reproduced on Mac OS 10.9.5 (yes, really old...):
Worked around / fixed with:
|
Digged further into this. Here's my understanding:
So this does seem like a Twisted related issue. Within my current understanding, addressing this may come down to design decisions around code I'm not totally familiar with:
I have no more time to dedicate to this today. My next steps would be:
PS: for some reason this only happens when certificate validation fails; I'm not seeing a single call to |
Short update:
|
The following may also be related: https://twistedmatrix.com/trac/ticket/7457 |
If it helps, I can generate the same error without treq using: |
@jlitzingerdev, thanks for the extra investigation. For easier reading, I've shortened your gist by quite a lot and created https://gist.github.com/exvito/b8298f25196d41daf67414f702518f6b I guess it is time to bring this topic to the Twisted mailing list. |
For a complete cross-reference, here's the message I posted to the Twisted mailing list: https://twistedmatrix.com/pipermail/twisted-python/2017-November/031730.html |
It has been awhile since the last update. Is it on the roadmap? |
@horkhe There is no roadmap; these are all volunteer-maintained projects with very limited resources. If you could write a PR that addresses the issue, it would probably get fixed faster ;). I’d very much like to see this traceback resolved too. |
The current specification for IBodyProducer states that implementations need to be written to allow simultaneous calls to pauseProducing, resumeProducing, and stopProducing. FileBodyProducer currently only complies with that for pause and resumeProducing (where comply is interpreted here as not raising an error). Instead of allowing the TaskFinished exception to be raised on multiple calls to stopProducing, catch and drop the exception. The use of "pass" is not ideal, but this avoids an internal book-keeping variable to track the stop state and a branch for the normal flow. The use of "pass" to handle stopped also appears within the inner maybeStopped function of startProducing, so it isn't without precedent. This has been discussed in several forums: * twisted/treq#185 (comment) * https://twistedmatrix.com/pipermail/twisted-python/2017-November/031730.html Related ticket(s): 7457 Regression risk: Existing uses of FileBodyProducer that rely on multiple calls to stopProducing to raise an exception will break.
This appears to be caused by the body producer's
stopProducing
method being called both by the TCP protocol and the TLS protocol:Occurs on other versions of Twisted and Treq as well.
Both calls appear to originate in this method of
tcp.Connection
:The text was updated successfully, but these errors were encountered: