Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f6ffb4b2
Commit
f6ffb4b2
authored
Jan 20, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
document that a new Python thread context is created in ctypes callbacks (closes #6627)
Patch by Nikolaus Rath.
parent
e83ed432
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
Doc/library/ctypes.rst
Doc/library/ctypes.rst
+7
-1
No files found.
Doc/library/ctypes.rst
View file @
f6ffb4b2
...
...
@@ -1022,12 +1022,18 @@ As we can easily check, our array is sorted now::
1 5 7 33 99
>>>
**Important note for callback functions:**
**Important note
s
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.
.. _ctypes-accessing-values-exported-from-dlls:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment