classification
Title: new thread doesn't copy context of the parent thread
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: adriangb, gvanrossum, jcea, uriyyo, yselivanov
Priority: normal Keywords: patch

Created on 2021-01-03 11:43 by uriyyo, last changed 2021-08-04 18:05 by adriangb.

Pull Requests
URL Status Linked Edit
PR 24074 open uriyyo, 2021-01-03 11:46
Messages (2)
msg384262 - (view) Author: Yurii Karabas (uriyyo) * (Python triager) Date: 2021-01-03 11:43
New thread doesn't copy context of the parent thread.

The minimal example to reproduce the issue:
```
from threading import Thread
from contextvars import ContextVar

foo: ContextVar[str] = ContextVar("foo")


def temp():
    print(foo.get())


foo.set("bar")

t = Thread(target=temp)
t.start()
t.join()
```

Is it expected behavior?

PEP 567 I didn't find anything regarding this case.
msg398642 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-07-31 14:51
Trust me, it's too late to fix this in 3.10.
History
Date User Action Args
2021-08-04 18:05:52adriangbsetnosy: + adriangb
2021-07-31 14:51:54gvanrossumsetnosy: + gvanrossum
messages: + msg398642
2021-07-31 14:20:10jceasetnosy: + jcea
2021-01-03 12:16:30vstinnersetnosy: + yselivanov
2021-01-03 11:46:40uriyyosetkeywords: + patch
stage: patch review
pull_requests: + pull_request22907
2021-01-03 11:43:34uriyyocreate