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
[C API] Remove PyEval_AcquireLock() and PyEval_ReleaseLock() functions #84179
Comments
The PyEval_AcquireLock() and PyEval_ReleaseLock() functions are misleading and deprecated since Python 3.2. bpo-10913 deprecated them: commit 5ace8e9
It's now time to remove them! I *discovered* these functions while working on bpo-39984. Previously, I never ever used them nor really see them. I only made refactoring them in their code, without paying attention to them. |
What's New In Python 3.2 says: |
PyEval_AcquireLock() is declared with Py_DEPRECATED(3.2) since Python 3.7 PyEval_ReleaseLock() is not declared with Py_DEPRECATED(), but PyEval_ReleaseLock() cannot be used without PyEval_AcquireLock(). |
We cannot just remove functions from stable ABI. We can undocument them, remove their declaration from header files, but we can't remove the implementation. Just make them always failing. |
See for example _PyTrash_deposit_object. |
Hum, I found multiple projects using PyEval_AcquireLock() and PyEval_ReleaseLock(). Many of them look abandonned. But a few were modified earlier than 1 year old. -- ntripcaster2: Latest commit on Jun 2019 Example: PyEval_AcquireLock (); maininterpreterstate = mainthreadstate->interp;
newthreadstate = PyThreadState_New (maininterpreterstate); PyEval_ReleaseLock (); -- I found usage of PyEval_AcquireLock() in an old version of pygame (1.9.1, latest is 1.9.6): PyEval_AcquireLock ();
oldstate = PyThreadState_Swap (helper->thread);
...
result = PyObject_CallFunction (helper->tell, NULL);
...
PyThreadState_Swap (oldstate);
PyEval_ReleaseLock (); pygame changed to "PyGILState_Ensure() ... PyGILState_Release()" instead. -- giljoy (Latest commit in 2013): it seems to override symloads using LD_PRELOAD to measure time when the GIL is acquired and released. https://github.com/itamarst/giljoy/blob/master/giljoy.c -- xmlbus: Latest commit in 2014. Example: PyEval_AcquireLock();
mainInterpreterState = mainThreadState->interp;
PyThreadState_Swap(mainThreadState);
myThreadState = PyThreadState_New(mainInterpreterState);
PyEval_ReleaseLock(); |
(Trashcan is somehow off-topic here, but let me comment anyway ;-))
I know that this one is kept for ABI backward compatibility... but the TRASHCAN API is excluded from the limited API. So I'm not sure that it is worth it to keep _PyTrash_deposit_object() in the ABI. I modified the TRASHCAN API in Python 3.9 to no longer leak implementation details (access PyThreadState structure fields). The implementation now only uses function calls. => commit 38965ec |
Oh no, PyEval_AcquireLock() and PyEval_ReleaseLock() are part of the limited C API (and so the stable ABI). Sadly, we have to keep them. I close the issue as rejected.
Alright, sadly it's part of the limited C API :-(
Since I found a few projects using these functions, I'm no longer sure that it's worth it to remove these functions. Continuing to maintain these functions is not really a major maintenance burden right now. So I simply close this issue. If someone disagree, you can propose an implementation of Serhiy's suggestion. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: