python-dependency-injector/docs/providers/coroutine.rst

28 lines
826 B
ReStructuredText
Raw Normal View History

Coroutine provider
2020-09-02 21:33:02 +00:00
==================
.. meta::
:keywords: Python,DI,Dependency injection,IoC,Inversion of Control,Coroutine,Asynchronous,
Asyncio,Example
:description: Coroutine provider creates a coroutine. This page demonstrates how to use a
Coroutine provider.
.. currentmodule:: dependency_injector.providers
:py:class:`Coroutine` provider creates a coroutine.
.. literalinclude:: ../../examples/providers/coroutine.py
:language: python
:lines: 3-
.. note::
The example works on Python 3.7+. For earlier versions use ``loop.run_until_complete()``.
``Coroutine`` provider handles an injection of the dependencies the same way like a
:ref:`factory-provider`.
.. note::
``Coroutine`` provider returns ``True`` for ``asyncio.iscoroutinefunction()`` check.
.. disqus::