(original) (raw)
On Sun, 7 Feb 2016 at 08:17 Daniel Miller <dalanmiller@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@python.org>:On Sat, 6 Feb 2016 at 13:50 Daniel Miller <dalanmiller@rethinkdb.com> wrote:Hi Python-Dev Group,I am trying to implement \_\_aenter\_\_ and \_\_aexit\_\_ for the RethinkDB 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?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\_\_.