gh-105766: Document that Custom Allocators Must Be Thread-Safe (gh-107519)

This commit is contained in:
Eric Snow 2023-07-31 17:11:15 -06:00 committed by GitHub
parent fb344e99aa
commit db361a340a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -476,6 +476,10 @@ Customize Memory Allocators
thread-safe: the :term:`GIL <global interpreter lock>` is not held when the
allocator is called.
For the remaining domains, the allocator must also be thread-safe:
the allocator may be called in different interpreters that do not
share a ``GIL``.
If the new allocator is not a hook (does not call the previous allocator),
the :c:func:`PyMem_SetupDebugHooks` function must be called to reinstall the
debug hooks on top on the new allocator.
@ -500,6 +504,8 @@ Customize Memory Allocators
**must** wrap the existing allocator. Substituting the current
allocator for some other arbitrary one is **not supported**.
.. versionchanged:: 3.12
All allocators must be thread-safe.
.. c:function:: void PyMem_SetupDebugHooks(void)