Skip to content

Commit 48f82d7

Browse files
[3.14] gh-154139: Document that curses is not thread-safe (GH-154173) (GH-155691)
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 9db2cad commit 48f82d7

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
@@ -34,6 +34,18 @@ Linux and the BSD variants of Unix.
3434
Whenever the documentation mentions a *character string* it can be specified
3535
as a Unicode string or a byte string.
3636

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

3951
Module :mod:`curses.ascii`

0 commit comments

Comments
 (0)