summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-01-20 05:12:24 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-01-20 05:12:24 (GMT)
commit27b490c71385341ce32c6540d98632032c440159 (patch)
tree43f82f3861d1ddf214ccee5849d4d0b054a560ac
parent665757847eddd2e4b211bd78d964171ba541731c (diff)
parent1cfe009b96e500034faf923fff8bbf87a4c7e182 (diff)
downloadcpython-27b490c71385341ce32c6540d98632032c440159.zip
cpython-27b490c71385341ce32c6540d98632032c440159.tar.gz
cpython-27b490c71385341ce32c6540d98632032c440159.tar.bz2
merge 3.3 (#6627)
-rw-r--r--Doc/library/ctypes.rst18
1 files changed, 12 insertions, 6 deletions
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index ae10b71..f46da85 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1022,12 +1022,18 @@ As we can easily check, our array is sorted now::
1 5 7 33 99
>>>
-**Important note for callback functions:**
-
-Make sure you keep references to :func:`CFUNCTYPE` objects as long as they are
-used from C code. :mod:`ctypes` doesn't, and if you don't, they may be garbage
-collected, crashing your program when a callback is made.
-
+.. note::
+
+ Make sure you keep references to :func:`CFUNCTYPE` objects as long as they
+ are used from C code. :mod:`ctypes` doesn't, and if you don't, they may be
+ garbage collected, crashing your program when a callback is made.
+
+ Also, note that if the callback function is called in a thread created
+ outside of Python's control (e.g. by the foreign code that calls the
+ callback), ctypes creates a new dummy Python thread on every invocation. This
+ behavior is correct for most purposes, but it means that values stored with
+ `threading.local` will *not* survive across different callbacks, even when
+ those calls are made from the same C thread.
.. _ctypes-accessing-values-exported-from-dlls: