Skip to content
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

Document that hypothesis is thread-unsafe #116

Open
ngoldbaum opened this issue Nov 19, 2024 · 5 comments
Open

Document that hypothesis is thread-unsafe #116

ngoldbaum opened this issue Nov 19, 2024 · 5 comments

Comments

@ngoldbaum
Copy link
Collaborator

See https://hypothesis.readthedocs.io/en/latest/details.html#thread-safety-policy and indygreg/python-zstandard#243 for a time this came up in the real world.

@ngoldbaum
Copy link
Collaborator Author

@Zac-HD as a hypothesis maintainer I'd appreciate your take on my assessment here.

@Zac-HD
Copy link

Zac-HD commented Nov 19, 2024

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: HypothesisWorks/hypothesis#4028

@colesbury
Copy link
Contributor

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?

@ngoldbaum
Copy link
Collaborator Author

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.

@Zac-HD
Copy link

Zac-HD commented Nov 22, 2024

The database is safe for concurrent use from multiple threads (it's a very basic best-effort KV store), entirely correct on the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants