Skip to content

Commit 4541e9e

Browse files
PEP 788: Final tweaks to improve clarity (#4678)
* Rename section for clarity on Py_IsFinalizing * Clarify non-releasing behavior * Fix contradicting text in PyInterpreterView_Copy() Also added double-spacing between functions. * Fix incorrect name in Rejected Ideas
1 parent 2325e57 commit 4541e9e

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

peps/pep-0788.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ This means that any non-Python thread may be terminated at any point, which
122122
severely limits users who want to do more than just execute Python
123123
code in their stream of calls.
124124

125-
``Py_IsFinalizing`` Is Not Atomic
126-
*********************************
125+
``Py_IsFinalizing`` Cannot Be Used Atomically
126+
*********************************************
127127

128128
Due to the problem mentioned previously, the :ref:`docs <python:gilstate>`
129129
currently recommend :c:func:`Py_IsFinalizing` to guard against termination of
@@ -354,7 +354,9 @@ Interpreter Guards
354354
.. c:function:: void PyInterpreterGuard_Close(PyInterpreterGuard guard)
355355
356356
Destroy an interpreter guard, allowing the interpreter to enter
357-
finalization if no other guards remain.
357+
finalization if no other guards remain. If an interpreter guard
358+
is never closed, the interpreter will infinitely wait when trying
359+
to enter finalization.
358360
359361
This function cannot fail, and the caller doesn't need to hold an
360362
:term:`attached thread state`.
@@ -371,6 +373,7 @@ Interpreter Views
371373
372374
This type is guaranteed to be pointer-sized.
373375
376+
374377
.. c:function:: PyInterpreterView PyInterpreterView_FromCurrent(void)
375378
376379
Create a view to the current interpreter.
@@ -383,23 +386,26 @@ Interpreter Views
383386

384387
The caller must hold an :term:`attached thread state`.
385388

389+
386390
.. c:function:: PyInterpreterView PyInterpreterView_Copy(PyInterpreterView view)
387391
388392
Duplicate a view to an interpreter.
389393
390394
On success, this function returns a non-zero copy of *view*; on failure,
391395
it returns ``0`` without an exception set.
392396

393-
This function cannot fail, and the caller doesn't need to hold an
394-
:term:`attached thread state`.
397+
The caller does not need to hold an :term:`attached thread state`.
398+
395399

396400
.. c:function:: void PyInterpreterView_Close(PyInterpreterView view)
397401
398-
Delete an interpreter view.
402+
Delete an interpreter view. If an interpreter view is never closed, the
403+
view's memory will never be freed.
399404
400405
This function cannot fail, and the caller doesn't need to hold an
401406
:term:`attached thread state`.
402407
408+
403409
.. c:function:: PyInterpreterView PyUnstable_InterpreterView_FromDefault()
404410
405411
Create a view for an arbitrary "main" interpreter.
@@ -429,6 +435,7 @@ replace :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`.
429435

430436
This type is guaranteed to be pointer-sized.
431437

438+
432439
.. c:function:: PyThreadView PyThreadState_Ensure(PyInterpreterGuard guard)
433440
434441
Ensure that the thread has an :term:`attached thread state` for the
@@ -449,9 +456,12 @@ replace :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`.
449456
Return a non-zero thread view of the old thread state on success, and
450457
``0`` on failure.
451458

459+
452460
.. c:function:: void PyThreadState_Release(PyThreadView view)
453461
454-
Release a :c:func:`PyThreadState_Ensure` call.
462+
Release a :c:func:`PyThreadState_Ensure` call. If this function is
463+
not called, the thread state created by :c:func:`PyThreadState_Ensure`,
464+
if any, will leak.
455465
456466
The :term:`attached thread state` before the corresponding
457467
:c:func:`PyThreadState_Ensure` call is guaranteed to be restored upon
@@ -903,8 +913,8 @@ hurt the proposal's goals:
903913

904914
.. _pep-788-activate-deactivate-instead:
905915

906-
Exposing an ``Activate``/``Deactivate`` API Instead of ``Ensure``/``Clear``
907-
---------------------------------------------------------------------------
916+
Exposing an ``Activate``/``Deactivate`` API Instead of ``Ensure``/``Release``
917+
-----------------------------------------------------------------------------
908918

909919
In prior discussions of this API, it was
910920
`suggested <https://discuss.python.org/t/83959/2>`_ to provide actual

0 commit comments

Comments
 (0)