|
@@ -1,6 +1,5 @@
|
|
|
from typing import Generic, TypeVar, Any
|
|
|
from contextlib import asynccontextmanager
|
|
|
-import asyncio
|
|
|
|
|
|
from ..types import Message, Context
|
|
|
|
|
@@ -19,9 +18,10 @@ class InjectorWithCleanup(Injector[Dep]):
|
|
|
|
|
|
@asynccontextmanager
|
|
|
async def inject_all(injectors: list[Injector[Any]], message: Message, context: Context):
|
|
|
- # TODO want to catch exceptions for the inject calls too to ensure cleanup
|
|
|
- deps = await asyncio.gather(*[inj.inject(message, context) for inj in injectors])
|
|
|
try:
|
|
|
+ deps = []
|
|
|
+ for inj in injectors:
|
|
|
+ deps.append(await inj.inject(message, context))
|
|
|
yield deps
|
|
|
finally:
|
|
|
for dep, inj in zip(deps, injectors):
|