Skip to content

Commit 69a6ee7

Browse files
committed
sim.core: add a warning about async generators on Python <= 3.12
1 parent 0f14153 commit 69a6ee7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

amaranth/sim/core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ async def testbench(ctx):
191191
which they were added. If two testbenches share state, or must manipulate the design in
192192
a coordinated way, they may rely on this execution order for correctness.
193193
194+
.. warning::
195+
196+
On Python 3.12 and earlier, async generators (:py:`async` functions that also
197+
:py:`yield`) are not cleaned up reliably when the simulator exits. To make sure context
198+
managers or :py:`finally` blocks inside async generators run properly, use Python 3.13
199+
or later.
200+
194201
Raises
195202
------
196203
:exc:`RuntimeError`
@@ -248,6 +255,13 @@ async def process(ctx):
248255
:py:`await ctx.tick().sample(...)`. Such state is visible in a waveform viewer,
249256
simplifying debugging.
250257
258+
.. warning::
259+
260+
On Python 3.12 and earlier, async generators (:py:`async` functions that also
261+
:py:`yield`) are not cleaned up reliably when the simulator exits. To make sure context
262+
managers or :py:`finally` blocks inside async generators run properly, use Python 3.13
263+
or later.
264+
251265
Raises
252266
------
253267
:exc:`RuntimeError`

0 commit comments

Comments
 (0)