Open ngoldbaum opened 1 week ago
@zac-hd as a hypothesis maintainer I'd appreciate your take on my assessment here.
You're correct that Hypothesis is not threadsafe. I haven't yet worked out what to do about that given free-threading changes; it'd be great to support but also we really do have to manage some global state.
Upstream issue: https://github.com/HypothesisWorks/hypothesis/issues/4028
Is this mostly a matter of not being able to use tools like pytest-run-parallel
with hypothesis or are there other general free-threading issues?
It's the same as pytest, it's fine to spawn worker threads in a hypothesis test but hypothesis itself has a lot of thread safety issues so if you use constructs provided by hypothesis in a multithreaded context or use hypothesis itself in many threads than you will likely hit issues. Lots of race conditions around global registries and that sort of thing. There's also an on-disk results db that may or may not have thread safety issues.
The database is safe for concurrent use from multiple threads (it's a very basic best-effort KV store), entirely correct on the rest.
See https://hypothesis.readthedocs.io/en/latest/details.html#thread-safety-policy and https://github.com/indygreg/python-zstandard/pull/243 for a time this came up in the real world.