Skip to content

Commit a29a65b

Browse files
[3.13] gh-154139: Document that curses is not thread-safe (GH-154173)
Whether curses is thread-safe depends on the library and how it was built. The blocking and refresh methods release the GIL, so with a non-reentrant curses, unsynchronized use from several threads can crash. The reference to window.use() and screen.use() is omitted: they were added in 3.16. (cherry picked from commit 1ed6b78) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ca981b1 commit a29a65b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Doc/library/curses.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ Linux and the BSD variants of Unix.
3232
Whenever the documentation mentions a *character string* it can be specified
3333
as a Unicode string or a byte string.
3434

35+
.. note::
36+
37+
Whether curses may be used from several threads
38+
depends on the underlying library and how it was built.
39+
In many implementations, including the default build of ncurses,
40+
the screen state is shared and not thread-safe;
41+
since the blocking and refresh methods
42+
(such as :meth:`~window.getch` and :meth:`~window.refresh`)
43+
release the :term:`GIL`,
44+
unsynchronized use from several threads can then crash the interpreter.
45+
Serialize the calls.
46+
3547
.. seealso::
3648

3749
Module :mod:`curses.ascii`

0 commit comments

Comments
 (0)