Skip to content

Commit adae494

Browse files
committed
Change some usage of the term 'global interpreter lock'
1 parent 166d970 commit adae494

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

Doc/c-api/init.rst

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -987,9 +987,7 @@ Most extension code manipulating the :term:`thread state` has the following simp
987987
structure::
988988
989989
Save the thread state in a local variable.
990-
Release the global interpreter lock.
991990
... Do some blocking I/O operation ...
992-
Reacquire the global interpreter lock.
993991
Restore the thread state from the local variable.
994992
995993
This is so common that a pair of macros exists to simplify it::
@@ -1371,39 +1369,37 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
13711369
13721370
.. c:function:: PyInterpreterState* PyInterpreterState_New()
13731371
1374-
Create a new interpreter state object. The global interpreter lock need not
1375-
be held, but may be held if it is necessary to serialize calls to this
1372+
Create a new interpreter state object. A :term:`thread state` need not
1373+
be attached, but may be held if it is necessary to serialize calls to this
13761374
function.
13771375
13781376
.. audit-event:: cpython.PyInterpreterState_New "" c.PyInterpreterState_New
13791377
13801378
13811379
.. c:function:: void PyInterpreterState_Clear(PyInterpreterState *interp)
13821380
1383-
Reset all information in an interpreter state object. The global interpreter
1384-
lock must be held.
1381+
Reset all information in an interpreter state object. A :term:`thread state`
1382+
for the interpreter must be attached.
13851383
13861384
.. audit-event:: cpython.PyInterpreterState_Clear "" c.PyInterpreterState_Clear
13871385
13881386
13891387
.. c:function:: void PyInterpreterState_Delete(PyInterpreterState *interp)
13901388
1391-
Destroy an interpreter state object. The global interpreter lock need not be
1392-
held. The interpreter state must have been reset with a previous call to
1389+
Destroy an interpreter state object. A :term:`thread state` for the interpreter
1390+
shouldn't be attached. The interpreter state must have been reset with a previous call to
13931391
:c:func:`PyInterpreterState_Clear`.
13941392
13951393
13961394
.. c:function:: PyThreadState* PyThreadState_New(PyInterpreterState *interp)
13971395
13981396
Create a new thread state object belonging to the given interpreter object.
1399-
The global interpreter lock need not be held, but may be held if it is
1400-
necessary to serialize calls to this function.
1401-
1397+
A :term:`thread state` can be optionally attached.
14021398
14031399
.. c:function:: void PyThreadState_Clear(PyThreadState *tstate)
14041400
1405-
Reset all information in a thread state object. The global interpreter lock
1406-
must be held.
1401+
Reset all information in a :term:`thread state` object. The
1402+
:term:`thread state` must be active for the current thread.
14071403
14081404
.. versionchanged:: 3.9
14091405
This function now calls the :c:member:`PyThreadState.on_delete` callback.
@@ -1415,16 +1411,15 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
14151411
14161412
.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)
14171413
1418-
Destroy a thread state object. The global interpreter lock need not be held.
1419-
The thread state must have been reset with a previous call to
1414+
Destroy a :term:`thread state`` object. The :term:`thread state` should not
1415+
be active. *tstate* must have been reset with a previous call to
14201416
:c:func:`PyThreadState_Clear`.
14211417
14221418
14231419
.. c:function:: void PyThreadState_DeleteCurrent(void)
14241420
1425-
Destroy the current thread state and release the global interpreter lock.
1426-
Like :c:func:`PyThreadState_Delete`, the global interpreter lock must
1427-
be held. The thread state must have been reset with a previous call
1421+
Destroy the active :term:`thread state` and detach it.
1422+
The current :term:`thread state` must have been reset with a previous call
14281423
to :c:func:`PyThreadState_Clear`.
14291424
14301425

0 commit comments

Comments
 (0)