.. _GatherSequentialAwaitRule:

=========================
GatherSequentialAwaitRule
=========================

Discourages awaiting coroutines in a loop as this will run them sequentially. Using ``asyncio.gather()`` will run them concurrently.

-------
Message
-------
Using await in a loop will run async function sequentially. Use asyncio.gather() to run async functions concurrently.

---------------
Has Autofix: No
---------------

-------------------
VALID Code Examples
-------------------

# 1:







.. code-block:: python


    async def async_foo():
        return await async_bar()





# 2:





path: :file:`foo/tests/test_foo.py`

.. code-block:: python


    # await in a loop is fine if it's a test.
    async def async_check_call():
        for _i in range(0, 2):
            await async_foo()





---------------------
INVALID Code Examples
---------------------

# 1:







.. code-block:: python


    async def async_check_call():
        for _i in range(0, 2):
            await async_foo()





# 2:







.. code-block:: python


    async def async_check_assignment():
        for _i in range(0, 2):
            x = await async_foo()





# 3:







.. code-block:: python


    async def async_check_list_comprehension():
        [await async_foo() for _i in range(0, 2)]




