[Python-ideas] Async API

Yury Selivanov yselivanov.ml at gmail.com
Thu Oct 25 17:12:11 CEST 2012


On 2012-10-25, at 10:44 AM, Guido van Rossum <guido at python.org> wrote:

> On Thu, Oct 25, 2012 at 6:37 AM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
>> ]On 2012-10-25, at 3:49 AM, Paul Colomiets <paul at colomiets.name> wrote:
>> 
>>> Hi Yury,
>>> 
>>> On Thu, Oct 25, 2012 at 9:18 AM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
>>>> Well, I couldn't resist and just implemented a *proof of concept* myself.
>>>> The patch is here: https://dl.dropbox.com/u/21052/gen_in_finally.patch
>>>> 
>>>> The patch adds 'gi_in_finally' read-only property to generator objects.
>>>> 
>>> 
>>> Why haven't you used my implementation?
>>> 
>>> http://bugs.python.org/issue14730
>> 
>> Because it's a different thing.  Yours is a PEP 419 implementation --
>> 'sys.setcleanuphook'.  Mine is a quick hack to add 'gi_in_finally' property
>> to generators and see how good/bad it is.
> 
> I feel it's a code smell if you need to use this feature a lot. If you
> need it rarely, well, use one of the existing work-arounds.

But the feature isn't going to be used by users directly.  It will be used 
only in scheduler implementations.  Users will just write 'finally' blocks 
and they will work as expected. This just makes coroutines look and behave 
more like ordinary functions.  Isn't it one of our goals--to make it 
convenient and reliable?

-
Yury


More information about the Python-ideas mailing list