-
Notifications
You must be signed in to change notification settings - Fork 60
Add CFFI thread safety docs #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a global lock like this is necessary it is not safe for more than one thread to simultaneously call into any part of the library.
Missing "if" or "when" in that sentence?
As of version 2.0, CFFI generates thread-safe bindings to C libraries.
What's new in 2.0 is the GIL-free version of CFFI. CFFI has always generated thread-safe bindings with its GIL-using version, and now in 2.0 it continues to do so in its GIL-free version. I think that most of what you say in your (otherwise great and useful!) text applies equally to both versions.
You’re right, what’s there right now isn’t correct. I’ll fix it tomorrow. Thanks for giving this a read. |
Fixed, I also took the opportunity to expand the text a little with some more advice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Matti Picus <[email protected]>
LGTM, will merge in a day or two unless another reviewer has more comments. |
c.f. #187
Adds new docs describing the thread safety guarantees CFFI offers. Includes a worked example demonstrating how to use a thread-unsafe C library safely with a
threading.Lock
.