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-entrance is given
to the context manager. If the intent of a Context Manager is to say
"no matter how this block is entered or exited, the context will be
correctly maintained", then this needs to be possible.

I think you're going to have to justify this a bit more. From my point of view, yielding does not leave the with block in any meaningful sense. Indeed I'd be quite hacked off with a file context manager that was so inefficient as to close the file on yielding a line, only to have to re-open and seek when it got control back.


--
Rhodri James *-* Kynesim Ltd
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to