[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-19 Thread Abdur-Rahmaan Janhangeer
Thanks for Mr David beazley's materials online, a beginner like me was able to understand this thread from the beginning. Rarely do i get to understand what the folks in here are rumbling about. He was also teaching compiler theory at university. Don't know if he ever contributed to CPython. Here'

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-19 Thread Brett Cannon
On Thu, Feb 18, 2021 at 9:04 PM Guido van Rossum wrote: > On Thu, Feb 18, 2021 at 8:23 PM Luciano Ramalho > wrote: > >> Thanks for your reply, Guido. >> >> On Fri, Feb 19, 2021 at 12:07 AM Guido van Rossum >> wrote: >> > Reading the doc section you link to, it's pretty clear that >> `@asyncio.c

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-19 Thread Guido van Rossum
I think that for this functionality (force the event loop to run), the trampoline just needs to define a function that returns a magic value and special-case that. The helper then becomes def __sleep0(): await The magic object may have to be something with an __await__() method. On Fri, Feb

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-19 Thread Paul Sokolovsky
Hello, On Fri, 19 Feb 2021 06:29:35 -0300 Luciano Ramalho wrote: > On Fri, Feb 19, 2021 at 4:08 AM Guido van Rossum > wrote: > > Can you try this? > > > > async def __sleep(self): > > await None > > That didn't work*, but this does: > > async def __sleep(): > return None > > Was th

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-19 Thread Luciano Ramalho
On Fri, Feb 19, 2021 at 6:29 AM Luciano Ramalho wrote: > async def __sleep(): > return None Sorry, I meant to write: async def __sleep0(): return None Since the idea is to replace the generator-based coroutine `__sleep0` in tasks.py [1] with a native coroutine. [1] https://github.com/

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-19 Thread Luciano Ramalho
On Fri, Feb 19, 2021 at 4:08 AM Guido van Rossum wrote: > 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, Fe

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-19 Thread Luciano Ramalho
On Fri, Feb 19, 2021 at 4:08 AM Guido van Rossum wrote: > Can you try this? > > async def __sleep(self): > await None Perhaps you meant this? async def __sleep0(): await None Either way, `await None` raises "TypeError: object NoneType can't be used in 'await' expression". Maybe I mis

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-18 Thread Guido van Rossum
Can you try this? async def __sleep(self): await None 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(): > "" > yield > > [1] >

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-18 Thread Luciano Ramalho
Follow up question: what's the plan to replace this use of `@types.coroutine` in `asyncio/tasks.py`? [1] @types.coroutine def __sleep0(): "" 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 Ram

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-18 Thread Luciano Ramalho
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

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-18 Thread Guido van Rossum
On Thu, Feb 18, 2021 at 8:23 PM Luciano Ramalho wrote: > Thanks for your reply, Guido. > > On Fri, Feb 19, 2021 at 12:07 AM Guido van Rossum > wrote: > > Reading the doc section you link to, it's pretty clear that > `@asyncio.coroutine` will be removed. > > The *Note* right at the top of [1] say

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-18 Thread Luciano Ramalho
Thanks for your reply, Guido. On Fri, Feb 19, 2021 at 12:07 AM Guido van Rossum wrote: > Reading the doc section you link to, it's pretty clear that > `@asyncio.coroutine` will be removed. The *Note* right at the top of [1] says "Support for generator-based coroutines is deprecated and is sched

[Python-Dev] Re: Clarification on the removal of generator-based coroutines in 3.10

2021-02-18 Thread Guido van Rossum
On Thu, Feb 18, 2021 at 3:57 PM Luciano Ramalho wrote: > I am not a Python core developer, but my question relates > to changes that are expected in Python 3.10, so I felt this was the > best forum to ask. Please let me know if I should discuss this > elsewhere or file a documentation bug. > > Fi