Re: [Python-Dev] PEP 525, fourth update

2016-09-07 Thread Guido van Rossum
Thanks Yury! (Everyone else following along, the PEP is accepted provisionally, and we may make small tweaks from time to time during Python 3.6's lifetime.) ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python

Re: [Python-Dev] PEP 525, fourth update

2016-09-07 Thread Yury Selivanov
Thank you, Guido! I've updated the PEP to make shutdown_asyncgens a coroutine, as we discussed. Yury On 2016-09-06 7:10 PM, Guido van Rossum wrote: Thanks Yury! I am hereby accepting PEP 525 provisionally. The acceptance is so that you can go ahead and merge this into 3.6 before the feat

Re: [Python-Dev] PEP 525, fourth update

2016-09-06 Thread Guido van Rossum
Thanks Yury! I am hereby accepting PEP 525 provisionally. The acceptance is so that you can go ahead and merge this into 3.6 before the feature freeze this weekend. The provisional status is because this is a big project and it's likely that we'll need to tweak some small aspect of the API once th

[Python-Dev] PEP 525, fourth update

2016-09-06 Thread Yury Selivanov
Hi, I've updated PEP 525 with a new section about asyncio changes. Essentially, asyncio event loop will get a new "shutdown_asyncgens" method that allows to close the loop and all associated AGs with it reliably. Only the updated section is pasted below: asyncio --- The asyncio event

Re: [Python-Dev] PEP 525, third round, better finalization

2016-09-03 Thread Greg Ewing
Nick Coghlan wrote: For synchronous code, that's a relatively easy burden to push back onto the programmer - assuming fair thread scheduling, a with statement can ensure reliably ensure prompt resource cleanup. That assurance goes out the window as soon as you explicitly pause code execution ins

Re: [Python-Dev] PEP 525, third round, better finalization

2016-09-03 Thread Yury Selivanov
Hi Oscar, I don't think PyPy is in breach of the language spec here. Python made a decision a long time ago to shun RAII-style implicit cleanup in favour if with-style explicit cleanup. The solution to this problem is to move resource management outside of the generator functions. This is true f

Re: [Python-Dev] PEP 525, third round, better finalization

2016-09-03 Thread Nick Coghlan
On 4 September 2016 at 04:38, Oscar Benjamin wrote: > On 3 September 2016 at 16:42, Nick Coghlan wrote: >> On 2 September 2016 at 19:13, Nathaniel Smith wrote: >>> This works OK on CPython because the reference-counting gc will call >>> handle.__del__() at the end of the scope (so on CPython it'

Re: [Python-Dev] PEP 525, third round, better finalization

2016-09-03 Thread Yury Selivanov
Hi Nathaniel, On 2016-09-02 2:13 AM, Nathaniel Smith wrote: On Thu, Sep 1, 2016 at 3:34 PM, Yury Selivanov wrote: Hi, I've spent quite a while thinking and experimenting with PEP 525 trying to figure out how to make asynchronous generators (AG) finalization reliable. I've tried to replace the

Re: [Python-Dev] PEP 525, third round, better finalization

2016-09-03 Thread Oscar Benjamin
On 3 September 2016 at 16:42, Nick Coghlan wrote: > On 2 September 2016 at 19:13, Nathaniel Smith wrote: >> This works OK on CPython because the reference-counting gc will call >> handle.__del__() at the end of the scope (so on CPython it's at level >> 2), but it famously causes huge problems whe

Re: [Python-Dev] PEP 525, third round, better finalization

2016-09-03 Thread Nick Coghlan
On 2 September 2016 at 19:13, Nathaniel Smith wrote: > This works OK on CPython because the reference-counting gc will call > handle.__del__() at the end of the scope (so on CPython it's at level > 2), but it famously causes huge problems when porting to PyPy with > it's much faster and more sophi

Re: [Python-Dev] PEP 525, third round, better finalization

2016-09-02 Thread Nathaniel Smith
On Thu, Sep 1, 2016 at 3:34 PM, Yury Selivanov wrote: > Hi, > > I've spent quite a while thinking and experimenting with PEP 525 trying to > figure out how to make asynchronous generators (AG) finalization reliable. > I've tried to replace the callback for GCed with a callback to intercept > first

[Python-Dev] PEP 525, third round, better finalization

2016-09-01 Thread Yury Selivanov
Hi, I've spent quite a while thinking and experimenting with PEP 525 trying to figure out how to make asynchronous generators (AG) finalization reliable. I've tried to replace the callback for GCed with a callback to intercept first iteration of AGs. Turns out it's very hard to work with we

Re: [Python-Dev] PEP 525

2016-08-25 Thread Nick Coghlan
On 25 August 2016 at 05:00, Yury Selivanov wrote: > On 2016-08-24 12:35 PM, Guido van Rossum wrote: >> Hopefully there will be other discussion as well, otherwise I'll have to >> accept the PEP once this issue is cleared up. :-) > > Curious to hear your thoughts on two different approaches to fina

Re: [Python-Dev] PEP 525

2016-08-24 Thread Sven R. Kunze
On 24.08.2016 21:05, Yury Selivanov wrote: Sorry for making you irritated. Please feel free to remind me about any concrete changes to the PEP that I promised to add on python-ideas. I'll go and re-read that thread right now anyways. No problem as it seems I wasn't the only one. So, it doesn

Re: [Python-Dev] PEP 525

2016-08-24 Thread Sven R. Kunze
On 24.08.2016 21:00, Yury Selivanov wrote: For an async generator there are two cases: either it tries to yield another value (the first time this happens you can throw an error back into it) or it tries to await -- in that case you can also throw an error back into it, and if the error comes

Re: [Python-Dev] PEP 525

2016-08-24 Thread Yury Selivanov
On 2016-08-24 3:01 PM, Sven R. Kunze wrote: On 24.08.2016 18:35, Guido van Rossum wrote: On Wed, Aug 24, 2016 at 8:17 AM, Yury Selivanov mailto:yselivanov...@gmail.com>> wrote: On 2016-08-23 10:38 PM, Rajiv Kumar wrote: I was playing with your implementation to gain a better

Re: [Python-Dev] PEP 525

2016-08-24 Thread Sven R. Kunze
On 24.08.2016 18:35, Guido van Rossum wrote: On Wed, Aug 24, 2016 at 8:17 AM, Yury Selivanov mailto:yselivanov...@gmail.com>> wrote: On 2016-08-23 10:38 PM, Rajiv Kumar wrote: I was playing with your implementation to gain a better understanding of the operation of asend()

Re: [Python-Dev] PEP 525

2016-08-24 Thread Yury Selivanov
On 2016-08-24 12:35 PM, Guido van Rossum wrote: On Wed, Aug 24, 2016 at 8:17 AM, Yury Selivanov mailto:yselivanov...@gmail.com>> wrote: On 2016-08-23 10:38 PM, Rajiv Kumar wrote: I was playing with your implementation to gain a better understanding of the operation of asen

Re: [Python-Dev] PEP 525

2016-08-24 Thread Guido van Rossum
On Wed, Aug 24, 2016 at 8:17 AM, Yury Selivanov wrote: > On 2016-08-23 10:38 PM, Rajiv Kumar wrote: > >> 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'

Re: [Python-Dev] PEP 525

2016-08-24 Thread Yury Selivanov
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 me

Re: [Python-Dev] PEP 525

2016-08-23 Thread Rajiv Kumar
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 th

[Python-Dev] PEP 525

2016-08-23 Thread Yury Selivanov
Hi, I think it's time to discuss PEP 525 on python-dev (pasted below). There were no changes in the PEP since I posted it to python-ideas a couple of weeks ago. One really critical thing that will block PEP acceptance is asynchronous generators (AG) finalization. The problem is to provide a re