-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add py free-threaded support + concurrent access test #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
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 |
|
@lysnikolaou good catch. Most failures turn encoder/decoder to "unhealthy" state (i.e. non-recoverable). Here error source is external to encoder/decoder, thus "unhealthy" state is not applied. Though, it is impossible to distinguish recoverable and unrecoverable errors (and, most likely problem in parameter parsing is programming, not runtime error), so I'm going to make this error also non-recoverable. Thanks. |
e434f25 to
c0baed1
Compare
By the way, I'd be happy to help out here if you're interested. |
a2d545b to
3f0175c
Compare
PiperOrigin-RevId: 830892275
3f0175c to
01c3f68
Compare
|
@eustas I think this is looking good! Anything holding up merging it? |
|
Please resolve git conflicts. |
Add py free-threaded support + concurrent access test