python-zstandard icon indicating copy to clipboard operation
python-zstandard copied to clipboard

Mention the free-threaded build in thread safety docs

Open ngoldbaum opened this issue 3 months ago • 1 comments

This is towards fully supporting the free-threaded build. I'm hoping this helps assuage the uncertainty described in c.f. https://github.com/indygreg/python-zstandard/pull/276#pullrequestreview-3148986714.

I think just documenting that the library is thread-unsafe is a minimal possible approach for supporting the free-threaded build. In this PR I implement that and document the limitations of sharing (de)compression contexts between threads, elaborating on the content that's already there for the GIL-enabled build.

In principle we can probably turn possible seg faults for not heeding these warnings into runtime exceptions, but I don't think that changes the content of what I'm proposing here much, so I thought I'd propose this first.

ngoldbaum avatar Sep 23 '25 18:09 ngoldbaum

@indygreg gentle ping on this - also if you're interested in further work along these lines I can look at ways to avoid segfaults without introducing runtime overhead.

ngoldbaum avatar Oct 21 '25 17:10 ngoldbaum