[issue33918] Hooking into pause/resume of iterators/coroutines

Liran Nuna report at bugs.python.org
Wed Jun 20 17:10:14 EDT 2018


Liran Nuna <liranuna at gmail.com> added the comment:

> You should try to use the contextvars module that was specifically created to handle local context state (for tasks & coroutines).

Yury, from my original report:

> I'm aware that this particular problem could be solved with the new context variables introduced with python3.7, however it is just a simplification of our actual issue.

Not everything can use context managers. Imagine the context manager is mock.patch used in testing and you want to run two tests in "parallel", each with a different mocked method. mock.patch isn't aware of `await` so patching will be incorrect.

Those are just some behaviors where context variables don't solve the issue I'm describing.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33918>
_______________________________________


More information about the Python-bugs-list mailing list