From cad3a5124f6f3cd4d1ced93b432a4cf28b8fbcfe Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Thu, 30 Nov 2023 12:08:55 +0100 Subject: [PATCH] Added web.AppRunner support. Signed-off-by: Pavel Kirilin --- taskiq_aiohttp/initializer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/taskiq_aiohttp/initializer.py b/taskiq_aiohttp/initializer.py index 66c165f..ffc7a26 100644 --- a/taskiq_aiohttp/initializer.py +++ b/taskiq_aiohttp/initializer.py @@ -96,11 +96,14 @@ async def startup(state: TaskiqState) -> None: app = import_object(app_path) - if not isinstance(app, web.Application): + if inspect.iscoroutinefunction(app): + app = await app() + elif inspect.isfunction(app): app = app() - if inspect.iscoroutine(app): - app = await app + if isinstance(app, web.AppRunner): + app = app.app + if not isinstance(app, web.Application): raise ValueError(f"{app_path} is not an AioHTTP application.")