[New-bugs-announce] [issue28725] Awaiting an awaitable returned from an async function does nothing

Gavin Panella report at bugs.python.org
Thu Nov 17 10:43:29 EST 2016


New submission from Gavin Panella:

The following will sleep:

  async def one():
      await asyncio.sleep(10)

  async def two():
      await one()

  loop.run_until_complete(two())

but the following will not:

  async def one():
      return asyncio.sleep(10)

  async def two():
      await one()

  loop.run_until_complete(two())

I would expect run_until_complete to keep bouncing awaitable results back into the event-loop until a non-awaitable is returned. In my code I work around this with:

  result = loop.run_until_complete(...)
  while inspect.isawaitable(result):
      result = loop.run_until_complete(result)

I would also expect that the await in `two` would have DTRT with the returned generator/coroutine.

----------
components: asyncio
messages: 281043
nosy: allenap, gvanrossum, yselivanov
priority: normal
severity: normal
status: open
title: Awaiting an awaitable returned from an async function does nothing
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28725>
_______________________________________


More information about the New-bugs-announce mailing list