[Python-checkins] cpython (merge 3.3 -> default): merge 3.3 (#6627)
benjamin.peterson
python-checkins at python.org
Mon Jan 20 06:12:38 CET 2014
http://hg.python.org/cpython/rev/fd647825475a
changeset: 88577:fd647825475a
parent: 88572:d0e2437136f5
parent: 88574:a6f748f40da6
user: Benjamin Peterson <benjamin at python.org>
date: Mon Jan 20 00:12:24 2014 -0500
summary:
merge 3.3 (#6627)
files:
Doc/library/ctypes.rst | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1022,12 +1022,18 @@
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:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list