Yury Selivanov added the comment: Alexander,
You don't need asyncio.isocoroutinefunction. Please use inspect.iscoroutinefunction and inspect.iscoroutine. Nick, 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29302> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com