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.")