[Python-Dev] PEP 0492 aenter & aexit (original) (raw)

Brett Cannon brett at python.org
Sun Feb 7 14:07:33 EST 2016


On Sun, 7 Feb 2016 at 08:17 Daniel Miller <dalanmiller at rethinkdb.com> wrote:

Awesome, I missed that. Thank you Brett.

Welcome!

Am I understanding correctly that if I'd like to avoid async with await_ _EXPR whatever is returned from EXPR must implement _await_ as a non-coroutine method? Which then I'd just be able to use async with ...?

Assuming I'm following what you're asking properly, aenter needs to return an awaitable: https://docs.python.org/3/reference/datamodel.html?#awaitable-objects. That is either an object that implements await() or a coroutine (which is basically a generator decorated with types.coroutine).

2016-02-06 16:05 GMT-06:00 Brett Cannon <brett at python.org>:

On Sat, 6 Feb 2016 at 13:50 Daniel Miller <dalanmiller at rethinkdb.com> wrote: Hi Python-Dev Group, I am trying to implement aenter and aexit for the RethinkDB <https://rethinkdb.com> Python driver. Looking at the PEP I don't see any definitions as to what the expected parameters that exit are supposed to take and couldn't find any other similar implementations. Is there a piece of documentation I should be looking at that I'm missing?

https://www.python.org/dev/peps/pep-0492/#asynchronous-context-managers-and-async-with The arguments to aexit are the same as exit in a normal context manager. See https://docs.python.org/3.5/reference/datamodel.html#object._aexit for the official docs for aexit. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160207/b8f3f4f0/attachment.html>



More information about the Python-Dev mailing list