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 <1488383126.54.0.38525740699.issue29302@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-03-01 15:45:26yselivanovsetrecipients: + yselivanov, gvanrossum, ncoghlan, vstinner, giampaolo.rodola, thehesiod, veky
2017-03-01 15:45:26yselivanovsetmessageid: <1488383126.54.0.38525740699.issue29302@psf.upfronthosting.co.za>
2017-03-01 15:45:26yselivanovlinkissue29302 messages
2017-03-01 15:45:26yselivanovcreate