mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 17:47:02 +03:00
c4b33749d2
* Update callable provider docs * Update coroutine provider docs * Edit object docs * Edit list provider docs * Edit configuration provider docs * Edit selector provider docs * Fix mypy stub of the ``DeclarativeContainer`` to specify the ``__init__`` interface * Edit Dependency provider docs
20 lines
451 B
Python
20 lines
451 B
Python
"""`Coroutine` providers example with async / await syntax."""
|
|
|
|
import asyncio
|
|
|
|
from dependency_injector import providers
|
|
|
|
|
|
async def coroutine(arg1, arg2):
|
|
await asyncio.sleep(0.1)
|
|
return arg1, arg2
|
|
|
|
|
|
coroutine_provider = providers.Coroutine(coroutine, arg1=1, arg2=2)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
arg1, arg2 = asyncio.run(coroutine_provider())
|
|
assert (arg1, arg2) == (1, 2)
|
|
assert asyncio.iscoroutinefunction(coroutine_provider)
|