[issue39998] [C API] Remove PyEval_AcquireLock() and PyEval_ReleaseLock() functions

STINNER Victor report at bugs.python.org
Fri Mar 20 13:21:43 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

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 

https://github.com/rinex20/ntripcaster2/blob/ef45763c4c0b063e46ef3bbfc9d63bafcd76e421/src/interpreter.c

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 ();

https://github.com/z-pan/pygame_tankScout/blob/7977cc6756e948c37cb4aa56fb1009a74288b65c/pygame-1.9.1release/src/rwobject.c

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.

https://github.com/olger/xmlbus/blob/148692997a481d10827a1aa86dc0ed3d70d84209/server/xmlbusd/pyrunner/pyrunner.c

Example:

	PyEval_AcquireLock();
	mainInterpreterState = mainThreadState->interp;
	PyThreadState_Swap(mainThreadState);

	myThreadState = PyThreadState_New(mainInterpreterState);
	PyEval_ReleaseLock();

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39998>
_______________________________________


More information about the Python-bugs-list mailing list