You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think Kumar wants to do it. Since in-depth free-threading knowledge is needed and the task is likely to be long (namely, there will be probably multiple PRs which may need to be synchronized with #128002), we should first determine which parts are not thread-safe and how we can make them so.
The sock_fd member of PySocketSockObject needs to be accessed by atomics because it can be accessed and modified concurrently by thread which may even not be holding the GIL. See also #116912
I think the fix would be make it thread safe by adding using relaxed atomics for sock_fd member.
Activity
WolframAlph commentedon Dec 27, 2024
Hi @kumaraditya303 @picnixz , is this one free to pick up or someone is working on it?
picnixz commentedon Dec 27, 2024
I think Kumar wants to do it. Since in-depth free-threading knowledge is needed and the task is likely to be long (namely, there will be probably multiple PRs which may need to be synchronized with #128002), we should first determine which parts are not thread-safe and how we can make them so.
kumaraditya303 commentedon Dec 27, 2024
Yeah, I had already started to work on this and you are correct it is needs to be synchronized with asyncio work.
picnixz commentedon Dec 27, 2024
(Just assigning you to the issue so that users know this without having to read the thread)
kumaraditya303 commentedon Dec 28, 2024
Reproducer:
The
sock_fdmember ofPySocketSockObjectneeds to be accessed by atomics because it can be accessed and modified concurrently by thread which may even not be holding the GIL. See also #116912I think the fix would be make it thread safe by adding using relaxed atomics for
sock_fdmember.gh-128277: use relaxed atomics for `sock_fd` (#128304)
gh-128277: make globals variables thread safe in socket module (#128286)
pythongh-128277: make globals variables thread safe in socket module (p…
gh-128277: remove unnecessary critical section from `socket.close` (#…
pythongh-128277: use relaxed atomics for `sock_fd` (python#128304)
pythongh-128277: make globals variables thread safe in socket module (p…
pythongh-128277: remove unnecessary critical section from `socket.clo…