diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-01-20 05:10:23 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-01-20 05:10:23 (GMT) |
commit | 1cfe009b96e500034faf923fff8bbf87a4c7e182 (patch) | |
tree | 4b67ca6440565bffd4de0e43a605b1571d9baebc /Doc/library | |
parent | f6ffb4b264ae2ac3e9086abb8c825b195b207bff (diff) | |
download | cpython-1cfe009b96e500034faf923fff8bbf87a4c7e182.zip cpython-1cfe009b96e500034faf923fff8bbf87a4c7e182.tar.gz cpython-1cfe009b96e500034faf923fff8bbf87a4c7e182.tar.bz2 |
put notes in a ..note section
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/ctypes.rst | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index f001165..f46da85 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1022,18 +1022,18 @@ As we can easily check, our array is sorted now:: 1 5 7 33 99 >>> -**Important notes 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. - -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. +.. 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: |