Skip to content
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

yield without try-except #76

Merged

Conversation

hhamana
Copy link
Collaborator

@hhamana hhamana commented Nov 26, 2022

Fix for #74 : yielding within a try-except block executes the exit code before a FastAPI error handler is executed, making the context unusable in such situations.
It looks like it didn't need to be in this block, as it is already within a context manager by itself.
Putting this up as I said I'd double check the fix, and haven't actually checked as thoroughly as I wanted but the idea is simple, it shouldn't have taken that long to fix.
https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/

Copy link
Owner

@tomwojcik tomwojcik left a comment

Choose a reason for hiding this comment

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

good catch

@tomwojcik tomwojcik merged commit 7eec35a into master Nov 26, 2022
@tomwojcik tomwojcik deleted the #74-ContextDoesNotExistError-on-FastAPI-error-handler branch November 26, 2022 15:10
@tomwojcik
Copy link
Owner

Released in https://github.com/tomwojcik/starlette-context/tree/v0.3.5

@tomwojcik
Copy link
Owner

tomwojcik commented Nov 26, 2022

It looks like it didn't need to be in this block, as it is already within a context manager by itself.

I'm not exactly sure this is correct but I was trying to run into regressions and I wasn't able to see any issues.

Putting this up as I said I'd double check the fix, and haven't actually checked as thoroughly as I wanted but the idea is simple, it shouldn't have taken that long to fix.

As I said above, it shouldn't result in any regressions and if true, this is a huge win as many people complained about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants