[Python-ideas] Letting context managers react to yields inside their scope

Yury Selivanov yselivanov.ml at gmail.com
Wed Apr 29 23:29:10 CEST 2015


Nathanial,

On 2015-04-29 4:22 PM, Nathaniel Smith wrote:
> Interaction with PEP 492
> ========================
>
> PEP 492 currently proposes an ``async with`` statement.  Despite the
> name, this is actually orthogonal to the proposal here: this PEP
> proposes to allow context managers to react to suspensions inside
> their scope, while ``async with`` makes context manager ``__enter__``
> and ``__exit__`` methods into potential ``yield`` points.  If both
> PEPs are accepted then we will presumably also want to add some kind
> of ``__asuspend__`` and ``__aresume__`` methods to PEP 492-style
> asynchronous context managers.
I doubt that we'll need __asuspend__.  There shouldn't be
a need to perform any blocking operations there.

__suspend__ and __resume__ would be enough.

Yury


More information about the Python-ideas mailing list