Skip to content

Commit 9eaab66

Browse files
committed
Experimental support for free-threaded Python.
1 parent b6bf0e4 commit 9eaab66

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### acefile 0.6.14-dev
22

3+
- Experimental support for free-threaded Python.
34
- Fix memory leak in acebitstream module.
45
- Add pytest smoke tests and configure GitHub Actions CI for testing.
56
- Remove deprecated setup.py features.

apidoc/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Typical use of :mod:`acefile` has the following structure:
2222
See :class:`acefile.AceArchive` and :class:`acefile.AceMember` for the
2323
complete descriptions of the methods supported by these two classes.
2424

25+
On free-threaded Python, :mod:`acefile` is only thread-safe as long as only a
26+
single thread operates on any given :class:`acefile.AceArchive` at a time.
27+
2528
Functions
2629
~~~~~~~~~
2730

c/acebitstream_mod.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,17 @@ PyInit_acebitstream(void)
290290
return NULL;
291291
}
292292

293+
#ifdef Py_GIL_DISABLED
294+
/*
295+
* There are no critical sections, because the premise is that
296+
* decompression from the same file-like object is inherently not
297+
* thread-safe. Decompressing archive members from the same non-solid
298+
* archive in parallel would need to be made thread-safe at a higher
299+
* layer than reading bits from a file-like object.
300+
*/
301+
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
302+
#endif
303+
293304
Py_INCREF(&BitStreamType);
294305
PyModule_AddObject(module, "BitStream", (PyObject*)&BitStreamType);
295306
return module;

0 commit comments

Comments
 (0)