Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix close call propagation of response in asgi/wsgi bridge #8926

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

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

thrau
Copy link
Member

@thrau thrau commented Aug 16, 2023

Motivation

During the implementation of the new S3 provider, we noticed that Response.close is never called on the werkzeug response, and therefore not propagated to other underlying objects. The test I added worked when serving it directly through the werkzeug server, and I found it's calling close here, where application_iter is the Response object.

We actually had no analogous call in our ASGI/WSGI bridge, so this PR adds that.

Changes

  • Encapsulate the sync/async iterable wrapper into a class and propagate any calls to aclose to the underlying close method.

I was briefly worried that this may break test_chunked_transfer_encoding_client_timeout but seems to still work, so although aclose is overwritten, it propagates the GeneratorExit exception correctly 👍

@thrau thrau requested a review from dfangl August 16, 2023 20:03
@thrau thrau added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Aug 16, 2023
@thrau thrau force-pushed the fix-request-closing branch from cb07d98 to 99d714e Compare August 16, 2023 20:05
@coveralls
Copy link

Coverage Status

coverage: 80.895% (-0.005%) from 80.9% when pulling 99d714e on fix-request-closing into 555f8da on master.

@github-actions
Copy link

LocalStack Community integration with Pro

       2 files         2 suites   1h 31m 9s ⏱️
2 084 tests 1 658 ✔️ 426 💤 0
2 085 runs  1 658 ✔️ 427 💤 0

Results for commit 99d714e.

Copy link
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants