This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yselivanov
Recipients giampaolo.rodola, gvanrossum, ncoghlan, thehesiod, veky, vstinner, yselivanov
Date 2017-03-01.15:45:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>

You don't need asyncio.isocoroutinefunction. Please use inspect.iscoroutinefunction and inspect.iscoroutine.


I'm +1 to have a separate class AsyncExitStack.

> - assume everything passed to it is a coroutine or an async context manager by default

I would add a separate set of methods prefixed with 'a' to handle async context managers.

> - always require close() to be called via await

I'd only have one coroutine 'aclose()' that would internally close sync and async context managers in the right order.

> - either add synchronous variants of the default-to-async methods (`enter_context_sync`, `push_sync`, `callback_sync`), or else make them auto-adapt to handle both synchronous and asynchronous inputs

I'd use the 'a' prefix. We use it already to name magic methods: __aenter__, __aexit__, __aiter__.

> - rather than using `iscoroutinefunction`, instead always invoke callbacks with await, and wrap synchronous callbacks supplied using the above methods in simple one-shot iterators

I'd favour a more explicit approach: separate methods for handling sync and async.

Also, speaking about asyncio dependancy -- we shouldn't have it. Using asyncio.iscoroutinefunction is unnecessary, inspect.iscoroutinefunction should be used instead.
Date User Action Args
2017-03-01 15:45:26yselivanovsetrecipients: + yselivanov, gvanrossum, ncoghlan, vstinner, giampaolo.rodola, thehesiod, veky
2017-03-01 15:45:26yselivanovsetmessageid: <>
2017-03-01 15:45:26yselivanovlinkissue29302 messages
2017-03-01 15:45:26yselivanovcreate