Re: [Python-ideas] Allow Context Managers to Support Suspended Execution

2018-11-01 Thread David Allemang
Yes, so PEP 512 is exactly what I was suggesting. My apologies for not finding it before sending this. So, then, PEP 567 solves the issue for coroutines and PEP 568 would solve it for generators as well? On Thu, Nov 1, 2018, 11:40 AM Yury Selivanov Yep, PEP 567 addresses this for coroutines, so

Re: [Python-ideas] Allow Context Managers to Support Suspended Execution

2018-11-01 Thread Yury Selivanov
Yep, PEP 567 addresses this for coroutines, so David's first example is covered; here's a link to the fixed version: [1] The proposal to add __suspend__ and __resume__ is very similar to PEP 521 which was withdrawn. PEP 568 (which needs to be properly updated) is the way to go if we want to addre

Re: [Python-ideas] Allow Context Managers to Support Suspended Execution

2018-11-01 Thread Guido van Rossum
Check out the decimal example here: https://www.python.org/dev/peps/pep-0568/ (PEP 568 is deferred, but PEP 567 is implemented in Python 3.7). Those Contexts aren't context managers, but still there's some thought put into swapping contexts out at the boundaries of generators. On Wed, Oct 31, 201

Re: [Python-ideas] Allow Context Managers to Support Suspended Execution

2018-11-01 Thread Calvin Spealman
I'm very curious about the idea, but can't come up with any use cases based just one your explanation. Maybe you could give some examples where this would be useful? In particular, what are some cases that are really hard to handle now and how would those cases be improved like this? On Wed, Oct 3

Re: [Python-ideas] Allow Context Managers to Support Suspended Execution

2018-11-01 Thread Rhodri James
On 01/11/2018 02:52, David Allemang wrote: I do not think there is currently a good way for Context Managers to support suspended execution, as in await or yield. Both of these instructions cause the interpreter to leave the with block, yet no indication of this (temporary) exit or subsequent re-

[Python-ideas] Allow Context Managers to Support Suspended Execution

2018-10-31 Thread David Allemang
I do not think there is currently a good way for Context Managers to support suspended execution, as in await or yield. Both of these instructions cause the interpreter to leave the with block, yet no indication of this (temporary) exit or subsequent re-entrance is given to the context manager. If