Alter ensure_sync implementation to support extensions

This allows extensions to override the Flask.ensure_sync method and
have the change apply to blueprints as well. Without this change it is
possible for differing blueprints to have differing ensure_sync
approaches depending on the extension used - which would likely result
in event-loop blocking issues.

This also allows blueprints to have a custom ensure_sync, although
this is a by product rather than an expected use case.
This commit is contained in:
pgjones 2021-03-24 20:47:55 +00:00 committed by David Lord
parent c6c6408c3f
commit 00f5a3e55c
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
5 changed files with 169 additions and 32 deletions

View file

@ -755,6 +755,7 @@ def run_async(func):
ctx module, except it has an async inner.
"""
ctx = None
if _request_ctx_stack.top is not None:
ctx = _request_ctx_stack.top.copy()