Skip to content

Commit e6fead2

Browse files
committed
Update docs regarding free-threading.
1 parent d5b1346 commit e6fead2

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
CPython on Windows. (Free-threaded CPython 3.13 may work, but is
1414
untested and unsupported.)
1515

16+
.. caution::
17+
18+
Under some rare scenarios, the interpreter may crash on accessing
19+
a variable or attribute or when shutting down. If this happens,
20+
try disabling the thread-local bytecode cache. See the greenlet
21+
documentation for more.
1622

1723
3.2.4 (2025-08-07)
1824
==================

docs/caveats.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@ lead to a hang.
3333

3434
See :issue:`143` for an example.
3535

36-
Free-threading Is Not Supported
37-
===============================
36+
Free-threading Is Experimental
37+
==============================
3838

39-
Beginning with 3.14 (and experimental in 3.13), CPython may be built
40-
in a free-threaded mode where the GIL is not used by default. greenlet
41-
does not support this mode (although it will build with it), and using
42-
greenlet in such an interpreter will cause the GIL to be enabled.
39+
Beginning with greenlet 3.3.0, support for Python 3.14's free-threaded
40+
mode is enabled. Use caution, as it has only limited testing.
4341

44-
In addition, there are known issues running greenlets in a
45-
free-threaded CPython. These include:
42+
There are known issues running greenlets in a free-threaded CPython.
43+
These include:
4644

45+
- As with any threaded program, use caution when forking. Greenlet
46+
maintains internal locks and forking at the wrong time might result
47+
in the child process hanging.
4748
- Garbage collection differences may cause ``GreenletExit`` to no
4849
longer be raised in certain multi-threaded scenarios.
4950
- There may be other memory leaks.
51+
- It may be necessary to disable the thread-local bytecode cache (and
52+
hence the specializing interpreter) to avoid a rare crash. If your
53+
process crashes on accessing an attribute or object, or at shutdown
54+
during module cleanup, try setting the environment variable
55+
``PYTHON_TLBC=0`` or using the ``-X tlbc=0`` argument.

docs/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ that since they're cooperatively scheduled, you are in control of
8080
when they execute, and since they are coroutines, many greenlets can
8181
exist in a single native thread.
8282

83-
Note that greenlet will cause a free-threaded build of Python to
84-
allocate a GIL, so no actual free-threading will take place. For more
83+
Beginning with greenlet 3.3, free-threaded builds of CPython are
84+
supported, but they have limited testing and some other limitations. For more
8585
on free-threading and greenlet, see :doc:`caveats`.
8686

8787
.. rubric:: How are greenlets different from threads?
@@ -106,9 +106,9 @@ implemented entirely without involving the operating system, they can
106106
require fewer resources; it is often practical to have many more
107107
greenlets than it is threads.
108108

109-
Note that greenlet will cause a free-threaded build of Python to
110-
allocate a GIL, so no actual free-threading will take place. For more
111-
on free-threading and greenlet, see :doc:`caveats`.
109+
Beginning with greenlet 3.3, you can combine threads and greenlets on
110+
free-threaded builds of CPython to take advantage of the strengths of
111+
both, but there may be limitations. See :doc:`caveats`.
112112

113113
.. _race conditions: https://en.wikipedia.org/wiki/Race_condition
114114
.. _deadlocks: https://docs.microsoft.com/en-us/troubleshoot/dotnet/visual-basic/race-conditions-deadlocks#when-deadlocks-occur

0 commit comments

Comments
 (0)