[Python-Dev] PEP 567 v2

Victor Stinner victor.stinner at gmail.com
Wed Jan 3 19:09:42 EST 2018


2018-01-04 0:44 GMT+01:00 Victor Stinner <victor.stinner at gmail.com>:
> The behaviour is more tricky than what I expected. While running
> context.run(), the context object is out of sync of the "current
> context". It's only synchronized again at run() exit. So
> ContextVar.set() doesn't immediately modifies the "current context"
> object (set by Context.run()).

A better description of Context.run() behaviour would be:

"Create a copy of the context and sets it as the current context. Once
the function completes, updates the context from the copy."

This description explains why run() doesn't immediately updates the
context object.

Victor


More information about the Python-Dev mailing list