[Python-Dev] PEP 525

Yury Selivanov yselivanov.ml at gmail.com
Wed Aug 24 11:17:53 EDT 2016


Hi Rajiv,

On 2016-08-23 10:38 PM, Rajiv Kumar wrote:
> Hi Yury,
>
> I was playing with your implementation to gain a better understanding 
> of the operation of asend() and friends. Since I was explicitly trying 
> to "manually" advance the generators, I wasn't using asyncio or other 
> event loop. This meant that the first thing I ran into with my toy 
> code was the RuntimeError ("cannot iterate async generator without 
> finalizer set").
>
> As you have argued elsewhere, in practice the finalizer is likely to 
> be set by the event loop. Since the authors of event loops are likely 
> to know that they should set the finalizer, would it perhaps be 
> acceptable to merely issue a warning instead of an error if the 
> finalizer is not set? That way there isn't an extra hoop to jump 
> through for simple examples.
>
> In my case, I just called
>     sys.set_asyncgen_finalizer(lambda g: 1)
> to get around the error and continue playing :) (I realize that's a 
> bad thing to do but it didn't matter for the toy cases)

Yeah, maybe warning would be sufficient.  I just find it's highly 
unlikely that a lot of people would use async generators without a 
loop/coroutine runner, as it's a very tedious process.

Thank you,
Yury


More information about the Python-Dev mailing list