From df06e1f4f01046fe5ef13b424383ffabe3ba53da Mon Sep 17 00:00:00 2001 From: Saunak <76943154+Saunakghosh10@users.noreply.github.com> Date: Mon, 17 Jul 2023 00:27:20 +0530 Subject: [PATCH] Modified the way before/teardown functions --- src/quart_injector/scope.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/quart_injector/scope.py b/src/quart_injector/scope.py index 1928050..f80a7d9 100644 --- a/src/quart_injector/scope.py +++ b/src/quart_injector/scope.py @@ -1,9 +1,4 @@ -""" -Request :class:`~injector.Scope`. -""" - import typing - import injector import quart import werkzeug.local @@ -69,8 +64,8 @@ async def before_func() -> None: async def teardown_func(_: BaseException | None) -> None: container.get(scope_cls).pop() - app.before_request_funcs[None].insert(0, before_func) - app.before_websocket_funcs[None].insert(0, before_func) + app.before_request_funcs[None] = [(before_func, None)] + app.before_request_funcs[None] + app.before_websocket_funcs[None] = [(before_func, None)] + app.before_websocket_funcs[None] - app.teardown_request_funcs[None].insert(0, teardown_func) - app.teardown_websocket_funcs[None].insert(0, teardown_func) + app.teardown_request_funcs[None] = [(teardown_func, None)] + app.teardown_request_funcs[None] + app.teardown_websocket_funcs[None] = [(teardown_func, None)] + app.teardown_websocket_funcs[None]