File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -406,6 +406,11 @@ This PEP specifies a breaking change with the removal of all the
406406``PyGILState`` APIs from the public headers of the non-limited C API in 10
407407years (Python 3.25).
408408
409+ Security Implications
410+ =====================
411+
412+ This PEP has no known security implications.
413+
409414How to Teach This
410415=================
411416
@@ -426,6 +431,12 @@ Ideally, they could be reused in the documentation.
426431Single-threaded example
427432***********************
428433
434+ This example shows acquiring a lock in a Python method.
435+
436+ If this were to be called from a daemon thread, then the interpreter could
437+ hang the thread while reattaching the thread state, leaving us with the lock
438+ held. Any future finalizer that wanted to acquire the lock would be deadlocked!
439+
429440.. code-block:: C
430441
431442 static PyObject *
@@ -440,13 +451,12 @@ Single-threaded example
440451
441452 Py_BEGIN_ALLOW_THREADS;
442453 acquire_some_lock();
443- /* If this were to be a daemon thread, then the interpreter could
444- hang the thread while reattaching the thread state, leaving us
445- with the lock held. Any future finalizer that wanted to acquire the
446- lock would be deadlocked!
447- */
448454 Py_END_ALLOW_THREADS;
449455
456+ /* Do something with the lock */
457+ // ...
458+
459+ release_some_lock();
450460 PyThreadState_Release();
451461 Py_RETURN_NONE;
452462 }
You can’t perform that action at this time.
0 commit comments