Andrew Svetlov <andrew.svet...@gmail.com> added the comment:
decimal was changed from threading.local to contextvar usage. The module is "safe" not only for asyncio but for threading, trio etc. unittest.mock doesn't use explicit context all for patching. It changes global interpreter-wide objects instead. So, mock.patch fails not only if two async tasks are executed in parallel but two threads also. I doubt if thread-local (or contextvar) can be applied to mock because it changes the current behavior -- but this is a different story. *Any* library that needs to modify a global state, e.g. your MyLogger.enabled can use contextvars for handling it. Say again, contextvars is not for asyncio-only but a generic instrument for handling context-aware variables. I'm going to close the issue. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33918> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com