]> granicus.if.org Git - python/commitdiff
Patch #893566: Document that tp_dealloc may be called from any thread.
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 15 Feb 2004 21:01:17 +0000 (21:01 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 15 Feb 2004 21:01:17 +0000 (21:01 +0000)
Doc/api/newtypes.tex

index 038cce9280bfda894aea12ffffd4a633d033112e..5b2e6cf7877d48743b1a975961eee9aba6a0f458 100644 (file)
@@ -1389,6 +1389,16 @@ inherited by subtypes.
   field.
 \end{cmemberdesc}
 
+Also, note that, in a garbage collected Python, tp_dealloc may be
+called from any Python thread, not just the thread which created the
+object (if the object becomes part of a refcount cycle, that cycle
+might be collected by a garbage collection on any thread).  This is
+not a problem for Python API calls, since the thread on which
+tp_dealloc is called will own the Global Interpreter Lock (GIL).
+However, if the object being destroyed in turn destroys objects from
+some other C or C++ library, care should be taken to ensure that
+destroying those objects on the thread which called tp_dealloc will
+not violate any assumptions of the library.
 
 \section{Mapping Object Structures \label{mapping-structs}}