Quansight-Labs / free-threaded-compatibility

A central repository to keep track of the status of work on and support for free-threaded CPython (see PEP 703), with a focus on the scientific and ML/AI ecosystem
https://py-free-threading.github.io/
MIT License
155 stars 22 forks source link

Add discussion of pytest thread safety #92

Closed ngoldbaum closed 2 weeks ago

ngoldbaum commented 1 month ago

Pytest isn't thread safe and it can be confusing if people expect it to be. We should document this.

Also similarly, the warnings module as a whole isn't thread safe. Temporary directories with named files or directories also have thread safety issues since they're using global state via the file system.

ogrisel commented 1 month ago

Non-exhaustive list of pytest tools that are inherently not thread-safe:

Usage of the tmpdir and tmp_path fixture is currently not thread-safe. However, they could probably be thread safe if the temporary folder they create for each test would be created and deleted within the same thread as the thread used to run them.