@@ -44,11 +44,15 @@ async def startup(state: TaskiqState) -> None:
4444
4545 if inspect .iscoroutine (local_app ):
4646 local_app = await local_app
47-
4847 if not isinstance (local_app , web .Application ):
4948 raise ValueError (f"{ app_path } is not an AioHTTP application." )
5049
51- handler = RequestHandler (local_app ._make_handler (), loop = loop )
50+ # Starting the application.
51+ app_runner = web .AppRunner (local_app )
52+ await app_runner .setup ()
53+
54+ # Creating mocked request
55+ handler = RequestHandler (app_runner .server , loop = loop )
5256 handler .transport = asyncio .Transport ()
5357 request = web .Request (
5458 RawRequestMessage (
@@ -88,9 +92,8 @@ async def startup(state: TaskiqState) -> None:
8892 },
8993 )
9094
91- state .aiohttp_app = local_app
95+ state .aiohttp_runner = app_runner
9296 local_app .router ._resources = []
93- await local_app .startup ()
9497
9598 return startup
9699
@@ -104,8 +107,8 @@ async def shutdown(state: TaskiqState) -> None:
104107
105108 :param state: current state.
106109 """
107- await state .aiohttp_app .shutdown ()
108- await state .aiohttp_app .cleanup ()
110+ await state .aiohttp_runner .shutdown ()
111+ await state .aiohttp_runner .cleanup ()
109112
110113
111114def init (broker : AsyncBroker , app_path : str ) -> None :
0 commit comments