3535from ninja .utils import check_csrf
3636
3737from ninja_extra .compatible import asynccontextmanager
38+ from ninja_extra .constants import ROUTE_CONTEXT_VAR
3839from ninja_extra .exceptions import APIException
3940from ninja_extra .helper import get_function_name
4041from ninja_extra .logger import request_logger
41- from ninja_extra .signals import route_context_finished , route_context_started
42+
43+ # from ninja_extra.signals import route_context_finished, route_context_started
4244from ninja_extra .types import PermissionType
4345
4446from .controllers .route .context import RouteContext , get_route_execution_context
@@ -153,7 +155,7 @@ def _prep_run(
153155 request , temporal_response = temporal_response , ** kw
154156 )
155157 # send route_context_started signal
156- route_context_started . send ( RouteContext , route_context = context )
158+ ROUTE_CONTEXT_VAR . set ( context )
157159
158160 yield context
159161 self ._log_action (
@@ -174,7 +176,7 @@ def _prep_run(
174176 raise e
175177 finally :
176178 # send route_context_finished signal
177- route_context_finished . send ( RouteContext , route_context = None )
179+ ROUTE_CONTEXT_VAR . set ( None )
178180
179181 def run (self , request : HttpRequest , ** kw : Any ) -> HttpResponseBase :
180182 error = self ._run_checks (request )
@@ -265,7 +267,7 @@ def _prep_run(
265267 request , temporal_response = temporal_response , ** kw
266268 )
267269 # send route_context_started signal
268- route_context_started . send ( RouteContext , route_context = context )
270+ ROUTE_CONTEXT_VAR . set ( context )
269271
270272 yield context
271273 self ._log_action (
@@ -286,7 +288,7 @@ def _prep_run(
286288 raise e
287289 finally :
288290 # send route_context_finished signal
289- route_context_finished . send ( RouteContext , route_context = None )
291+ ROUTE_CONTEXT_VAR . set ( None )
290292
291293 def run (self , request : HttpRequest , ** kw : Any ) -> HttpResponseBase :
292294 error = self ._run_checks (request )
@@ -363,7 +365,7 @@ async def _prep_run( # type:ignore
363365 start_time = time .time ()
364366 context = self .get_execution_context (request , ** kw )
365367 # send route_context_started signal
366- route_context_started . send ( RouteContext , route_context = context )
368+ ROUTE_CONTEXT_VAR . set ( context )
367369
368370 yield context
369371 self ._log_action (
@@ -384,7 +386,7 @@ async def _prep_run( # type:ignore
384386 raise e
385387 finally :
386388 # send route_context_finished signal
387- route_context_finished . send ( RouteContext , route_context = None )
389+ ROUTE_CONTEXT_VAR . set ( None )
388390
389391 async def run (self , request : HttpRequest , ** kw : Any ) -> HttpResponseBase : # type: ignore
390392 error = await self ._run_checks (request )
@@ -413,7 +415,7 @@ async def _prep_run( # type:ignore
413415 start_time = time .time ()
414416 context = self .get_execution_context (request , ** kw )
415417 # send route_context_started signal
416- route_context_started . send ( RouteContext , route_context = context )
418+ ROUTE_CONTEXT_VAR . set ( context )
417419
418420 yield context
419421 self ._log_action (
@@ -434,7 +436,7 @@ async def _prep_run( # type:ignore
434436 raise e
435437 finally :
436438 # send route_context_finished signal
437- route_context_finished . send ( RouteContext , route_context = None )
439+ ROUTE_CONTEXT_VAR . set ( None )
438440
439441 async def run (self , request : HttpRequest , ** kw : Any ) -> HttpResponseBase : # type: ignore
440442 error = await self ._run_checks (request )
0 commit comments