Closed
Description
Feature or enhancement
The I/O objects, like io.BufferedIOBase
, io.TextIOWrapper
, and io.StringIO
have internal state that would not be thread-safe without the GIL.
We should be able to mostly use Argument Clinic's (AC) support for "critical sections" to guard methods on these objects. For operations that don't use AC, we can either convert them to use AC or write the Py_BEGIN_CRITICAL_SECTION
/Py_END_CRITICAL_SECTION
manually.
For context, here are the similar modifications in the nogil-3.12
fork, but the implementation in CPython 3.13 will be a bit different (no need for extra locks, use the syntax from #111903):
- colesbury/nogil-3.12@ffade9d6f6 (PR by @Mayuresh16)
- colesbury/nogil-3.12@5b83c16dcd (PR by @aisk)
- colesbury/nogil-3.12@6323ca60f9 (PR by @aisk)