Merge app and request contexts into a single context (#5639) #5705
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merge app and request contexts into a single context (#5639)
This PR implements the proposal from #5639 to merge the app and request contexts into a single execution context. This simplifies the implementation by:
ExecutionContext
class that combines both app and request contexts_cv_execution
instead of separate_cv_app
and_cv_request
Key changes:
ExecutionContext
class inctx.py
that handles both app and request contextsglobals.py
to use the new execution context for all proxiesapp.py
to create execution contexts instead of separate app/request contextshas_app_context()
andhas_request_context()
The changes maintain backward compatibility while paving the way for a cleaner implementation in Flask 4.0. The new execution context:
This change will make the codebase simpler and easier to understand, while also making it more efficient by reducing the number of context variables that need to be managed.
Closes #5639