Skip to content

Commit 4951a11

Browse files
[3.15] gh-154139: Document that curses is not thread-safe (GH-154173) (#155690)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent f47da0f commit 4951a11

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

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

3648
Module :mod:`curses.ascii`

0 commit comments

Comments
 (0)