Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio module state should be locked with mutexes in free-threaded builds #121621

Closed
Fidget-Spinner opened this issue Jul 11, 2024 · 2 comments
Closed
Labels
topic-free-threading type-feature A feature request or enhancement

Comments

@colesbury
Copy link
Contributor

I think we also want to make enter_task, leave_task, and swap_current_task behave atomically. For example, enter_task makes two dict API calls that individually lock the dictionary, but the combined operation isn't atomic.

I can think of two strategies for this:

  1. Try to replace multiple API calls with a single call. For example, I think enter_task may be able to use PyDict_SetDefaultRef and leave_task may be able to use _PyDict_DelItemIf with some modifications.
  2. Use a critical section to lock the dict and use the "lock held" variants.

kumaraditya303 added a commit that referenced this issue Jul 14, 2024
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
colesbury pushed a commit to colesbury/cpython that referenced this issue Jul 14, 2024
…onGH-121622)

(cherry picked from commit 5d6861a)

Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
kumaraditya303 added a commit that referenced this issue Jul 15, 2024
…#121774)

(cherry picked from commit 5d6861a)

Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 16, 2024
…121695)

(cherry picked from commit 69c68de)

Co-authored-by: Ken Jin <kenjin@python.org>
Fidget-Spinner added a commit that referenced this issue Jul 16, 2024
… (GH-121864)

gh-121621: Move asyncio running loop to thread state (GH-121695)
(cherry picked from commit 69c68de)

Co-authored-by: Ken Jin <kenjin@python.org>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
colesbury added a commit to colesbury/cpython that referenced this issue Jul 17, 2024
This avoids changing the ABI and keeps the field in the private struct.
Yhg1s pushed a commit that referenced this issue Jul 17, 2024
This avoids changing the ABI and keeps the field in the private struct.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 17, 2024
…H-121939)

This avoids changing the ABI and keeps the field in the private struct.
(cherry picked from commit 81fd625)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Yhg1s pushed a commit that referenced this issue Jul 18, 2024
) (#121943)

gh-121621: Move asyncio_running_loop to private struct (GH-121939)

This avoids changing the ABI and keeps the field in the private struct.
(cherry picked from commit 81fd625)

Co-authored-by: Sam Gross <colesbury@gmail.com>
colesbury added a commit to colesbury/cpython that referenced this issue Jul 19, 2024
The futureobj freelist isn't thread-safe. We intend to re-enable the
freelist in a thread-safe way for 3.14 (but not 3.13).
colesbury added a commit that referenced this issue Jul 19, 2024
The futureobj freelist isn't thread-safe. We intend to re-enable the
freelist in a thread-safe way for 3.14 (but not 3.13).
colesbury added a commit to colesbury/cpython that referenced this issue Jul 19, 2024
…ld (pythonGH-122046)

The futureobj freelist isn't thread-safe. We intend to re-enable the
freelist in a thread-safe way for 3.14 (but not 3.13).
(cherry picked from commit 9724820)

Co-authored-by: Sam Gross <colesbury@gmail.com>
colesbury added a commit that referenced this issue Jul 19, 2024
…-122046) (#122048)

The futureobj freelist isn't thread-safe. We intend to re-enable the
freelist in a thread-safe way for 3.14 (but not 3.13).
(cherry picked from commit 9724820)
@Fidget-Spinner
Copy link
Member Author

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-free-threading type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants