gh-105182: Remove PyEval_AcquireLock() and PyEval_InitThreads() (#105… · python/cpython@ec0082c

GitHub

@@ -59,7 +59,7 @@ The following functions can be safely called before Python is initialized:

5959:c:func:`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`,

6060:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,

6161:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`,

62-:c:func:`Py_GetProgramName` and :c:func:`PyEval_InitThreads`.

62+ and :c:func:`Py_GetProgramName`.

636364646565.. _global-conf-vars:

@@ -326,7 +326,6 @@ Initializing and finalizing the interpreter

326326.. c:function::voidPy_Initialize()

327327328328 .. index::

329- single: PyEval_InitThreads()

330329 single: modules (in module sys)

331330 single: path (in module sys)

332331 pair: module; builtins

@@ -813,45 +812,6 @@ code, or when embedding the Python interpreter:

813812 this thread's interpreter state.

814813815814816-.. c:function:: void PyEval_InitThreads()

817-818- .. index::

819- single: PyEval_AcquireThread()

820- single: PyEval_ReleaseThread()

821- single: PyEval_SaveThread()

822- single: PyEval_RestoreThread()

823-824- Deprecated function which does nothing.

825-826- In Python 3.6 and older, this function created the GIL if it didn't exist.

827-828- .. versionchanged:: 3.9

829- The function now does nothing.

830-831- .. versionchanged:: 3.7

832- This function is now called by :c:func:`Py_Initialize()`, so you don't

833- have to call it yourself anymore.

834-835- .. versionchanged:: 3.2

836- This function cannot be called before :c:func:`Py_Initialize()` anymore.

837-838- .. deprecated:: 3.9

839-840- .. index:: pair: module; _thread

841-842-843-.. c:function:: int PyEval_ThreadsInitialized()

844-845- Returns a non-zero value if :c:func:`PyEval_InitThreads` has been called. This

846- function can be called without holding the GIL, and therefore can be used to

847- avoid calls to the locking API when running single-threaded.

848-849- .. versionchanged:: 3.7

850- The :term:`GIL` is now initialized by :c:func:`Py_Initialize()`.

851-852- .. deprecated:: 3.9

853-854-855815.. c:function:: PyThreadState* PyEval_SaveThread()

856816857817 Release the global interpreter lock (if it has been created) and reset the

@@ -1223,39 +1183,6 @@ All of the following functions must be called after :c:func:`Py_Initialize`.

12231183 available (even when threads have not been initialized).

12241184122511851226-.. c:function:: void PyEval_AcquireLock()

1227-1228- Acquire the global interpreter lock. The lock must have been created earlier.

1229- If this thread already has the lock, a deadlock ensues.

1230-1231- .. deprecated:: 3.2

1232- This function does not update the current thread state. Please use

1233- :c:func:`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread`

1234- instead.

1235-1236- .. note::

1237- Calling this function from a thread when the runtime is finalizing

1238- will terminate the thread, even if the thread was not created by Python.

1239- You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to

1240- check if the interpreter is in process of being finalized before calling

1241- this function to avoid unwanted termination.

1242-1243- .. versionchanged:: 3.8

1244- Updated to be consistent with :c:func:`PyEval_RestoreThread`,

1245- :c:func:`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`,

1246- and terminate the current thread if called while the interpreter is finalizing.

1247-1248-1249-.. c:function:: void PyEval_ReleaseLock()

1250-1251- Release the global interpreter lock. The lock must have been created earlier.

1252-1253- .. deprecated:: 3.2

1254- This function does not update the current thread state. Please use

1255- :c:func:`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread`

1256- instead.

1257-1258-12591186.. _sub-interpreter-support:

1260118712611188Sub-interpreter support