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 ncoghlan
Recipients Ilya.Kulakov, cheryl.sabella, giampaolo.rodola, ncoghlan, njs, privatwolke, thehesiod, veky, yselivanov
Date 2018-01-20.15:43:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516463022.2.0.467229070634.issue29302@psf.upfronthosting.co.za>
In-reply-to
Content
Explicitly noting some API design decisions from the review of https://github.com/python/cpython/pull/4790:

1. AsyncExitStack will define __aenter__ and __aexit__ but *not* __enter__ and __exit. This makes it unambiguous which form of with statement you need to be using for a given stack.
2. AsyncExitStack will use the same methods to add synchronous context managers as ExitStack does
3. The only common method with clearly distinct external behaviour will be stack.close(), which will be a coroutine in the AsyncExitStack case (the other common methods will all still be synchronous in AsyncExitStack)
4. AsyncExitStack will gain 3 new methods for working with async context managers:

- enter_async_context(cm): coroutine to enter an async context manager and adds its __aexit__ to the context stack if __aenter__ succeeds
- push_async_exit(cm_or_exit): push an exit callback directly onto the stack. The argument must either be an object implementing __aexit__, or else a callback with the same signature as __aexit__ (use stack.push() to register a synchronous CM or exit callback)
- push_async_callback(callback): push the given callback onto the stack. The callback should return an awaitable (use stack.callback() to register synchronous callbacks)
History
Date User Action Args
2018-01-20 15:43:42ncoghlansetrecipients: + ncoghlan, giampaolo.rodola, njs, yselivanov, thehesiod, veky, Ilya.Kulakov, cheryl.sabella, privatwolke
2018-01-20 15:43:42ncoghlansetmessageid: <1516463022.2.0.467229070634.issue29302@psf.upfronthosting.co.za>
2018-01-20 15:43:42ncoghlanlinkissue29302 messages
2018-01-20 15:43:41ncoghlancreate