On Fri, Feb 19, 2021 at 4:08 AM Guido van Rossum
Can you try this?
async def __sleep(self): await None
That didn't work*, but this does: async def __sleep(): return None Was that the idea? (*) TypeError: object NoneType can't be used in 'await' expression
On Thu, Feb 18, 2021 at 22:31 Luciano Ramalho
wrote: Follow up question: what's the plan to replace this use of `@types.coroutine` in `asyncio/tasks.py`? [1]
@types.coroutine def __sleep0(): """<docstring omitted>""" yield
[1] https://github.com/python/cpython/blob/master/Lib/asyncio/tasks.py#L585
Best,
Luciano
On Fri, Feb 19, 2021 at 2:31 AM Luciano Ramalho
wrote: On Fri, Feb 19, 2021 at 1:59 AM Guido van Rossum
wrote: 1) What Python construct is to be used at the end of a chain of await calls, if not of a generator-based coroutine decorated with `@types.coroutine` and using a `yield` expression in its body?
At the end of the chain you can call the __await__() method which gives an iterator, and then you call next() or send() on that iterator. Each next()/send() call then represents an await step, and send() in general is used to provide an awaited result. Eventually this will raise StopIteration with a value indicating the ultimate result (the return value of the top-level async def).
All right, that made sense to me. Thank you so much, Guido.
Thanks for the clarification about `@types.coroutine` as well.
Take care,
Luciano
-- Luciano Ramalho | Author of Fluent Python (O'Reilly, 2015) | http://shop.oreilly.com/product/0636920032519.do | Technical Principal at ThoughtWorks | Twitter: @ramalhoorg
-- Luciano Ramalho | Author of Fluent Python (O'Reilly, 2015) | http://shop.oreilly.com/product/0636920032519.do | Technical Principal at ThoughtWorks | Twitter: @ramalhoorg
-- --Guido (mobile)
-- Luciano Ramalho | Author of Fluent Python (O'Reilly, 2015) | http://shop.oreilly.com/product/0636920032519.do | Technical Principal at ThoughtWorks | Twitter: @ramalhoorg