-
Notifications
You must be signed in to change notification settings - Fork 124
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
fix: response leak when using caching adapter and streaming #344
Conversation
response._update_chunk_length = types.MethodType( # type: ignore[method-assign] | ||
_update_chunk_length, response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you assign a method like this, you're creating a circular reference to self
, because when you normally call response._update_chunk_length
, it actually creates the bound method on-the-fly, it's not set there all the time.
This SO response helped me understand it: https://stackoverflow.com/a/26158130
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch and fix. I would like to accept this. And I will wait for the inputs from @woodruffw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, makes sense to me as well. I appreciate the additional unit test!
Hi, when can we expect this being released to pypi? |
Assuming nothing else comes up, I'll cut a release in the next day or so. |
Currently, this library breaks
requests
behavior, where the finalizer will close response if user forges to call close. Use WeakRefs to prevent this.