-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-133171: Make the executor_list thread-safe #140038
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure that a mutex is safe here, because we're locking code paths that call Py_DECREF. @Fidget-Spinner, can these paths escape?
| #endif | ||
|
|
||
| // Executor list lock macros for thread-safe access to executor linked lists | ||
| #define EXECUTOR_LIST_LOCK(interp) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of FT_MUTEX_LOCK is to prevent macros like this. If you're really against repeating interp->executor_list_lock several times, you can define a macro for that instead.
|
In theory, |
|
I am not sure if making executor_list operations thread-safe at this point is good idea. |
The idea is simple and naive: just add a
PyMutexto thePyInterpreterStatefor theexecutor_listunder thenogilbuild, and lock or unlock the mutex in all functions that operate on theexecutor_list.Since I'm not very familiar with the related code, there might be a better way to do this, so any feedback would be appreciated!