docs: more warnings about locking and the GIL (#5689)

* docs: more warnings about locking and the GIL

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* fix require → reacquire typo

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
This commit is contained in:
Henry Schreiner
2025-05-24 19:12:49 -04:00
committed by GitHub
parent d7769de533
commit 9d06626521
2 changed files with 16 additions and 3 deletions

View File

@@ -365,8 +365,13 @@ TEST_CASE("Threads") {
py::gil_scoped_acquire gil{};
#ifdef Py_GIL_DISABLED
# if PY_VERSION_HEX < 0x030E0000
// This will not run with the GIL, so it won't deadlock. That's
// because of how we run our tests. Be more careful of
// deadlocks if the "free-threaded" GIL could be enabled (at
// runtime).
std::lock_guard<std::mutex> lock(mutex);
# else
// CPython's thread-safe API in no-GIL mode.
py::scoped_critical_section lock(locals);
# endif
#endif