Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3f4a1a

Browse files
committed
Patch #893566: Document that tp_dealloc may be called from any thread.
1 parent 7db04e7 commit d3f4a1a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Doc/api/newtypes.tex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,16 @@ \section{Type Objects \label{type-structs}}
13891389
field.
13901390
\end{cmemberdesc}
13911391

1392+
Also, note that, in a garbage collected Python, tp_dealloc may be
1393+
called from any Python thread, not just the thread which created the
1394+
object (if the object becomes part of a refcount cycle, that cycle
1395+
might be collected by a garbage collection on any thread). This is
1396+
not a problem for Python API calls, since the thread on which
1397+
tp_dealloc is called will own the Global Interpreter Lock (GIL).
1398+
However, if the object being destroyed in turn destroys objects from
1399+
some other C or C++ library, care should be taken to ensure that
1400+
destroying those objects on the thread which called tp_dealloc will
1401+
not violate any assumptions of the library.
13921402

13931403
\section{Mapping Object Structures \label{mapping-structs}}
13941404

0 commit comments

Comments
 (0)