Message288761
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. |
|
Date |
User |
Action |
Args |
2017-03-01 15:45:26 | yselivanov | set | recipients:
+ yselivanov, gvanrossum, ncoghlan, vstinner, giampaolo.rodola, thehesiod, veky |
2017-03-01 15:45:26 | yselivanov | set | messageid: <1488383126.54.0.38525740699.issue29302@psf.upfronthosting.co.za> |
2017-03-01 15:45:26 | yselivanov | link | issue29302 messages |
2017-03-01 15:45:26 | yselivanov | create | |
|