-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add py free-threaded support #1386
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: master
Are you sure you want to change the base?
Conversation
e89e64c to
c3911ac
Compare
2f66cfe to
f95ea76
Compare
f57fb4f to
134d504
Compare
Modernize testing (-> re-enable tests on Windows) PiperOrigin-RevId: 830892275
134d504 to
e434f25
Compare
|
@ngoldbaum I would be happy if you take another look. Thanks in advance. |
What is your testing strategy? I don't see any existing tests using You could look at using pytest-run-parallel to run the existing unit tests in a multithreaded context. This will mostly shake out use of global state in the implementation of the extension or in the brotli library itself. Given that the existing test suite makes heavy use of temporary files being written to disk with explicit names, I don't think it makes sense to focus on making the test suite thread-safe, so I probably wouldn't use pytest-run-parallel here. You'll get more more benefit from adding tests that explicitly share a Compressor or Decompressor between threads. When I write tests like this, I try to come up with an operation that can be divided into many steps that can be distributed across a thread pool. You'd then write a worker function that processes a block of data using a shared mutable data structure and exercises as much of the API as possible. Here's a test like this I wrote yesterday: https://github.com/ngoldbaum/preshed/blob/a2246dacd93de8b7ebe8c2665331b60d46111cf3/preshed/tests/test_multithreaded.py#L52-L88 If you want to be extra sure you're not triggering thread safety issues, you can run the multithreaded tests you end up with using a TSan instrumented build of CPython and brotli. See here for more details on using TSan to validate thread safety. |
|
In addition to the issue @ngoldbaum mentioned, I think |
Add py free-threaded support
Modernize testing (-> re-enable tests on Windows)