-
Notifications
You must be signed in to change notification settings - Fork 184
Open
Labels
Description
(Originally posted to #1590, but in a new issue for visibility and tracking.)
I'm getting RuntimeErrors during simulation when I use a background process that does not complete by the time the simulation ends. Here is a small example:
import amaranth as am
import amaranth.sim
async def deadline_checker(ctx):
await ctx.tick().repeat(100)
raise RuntimeError('deadline')
m = am.Module()
counter = am.Signal(8)
m.d.sync += counter.eq(counter + 1)
sim = am.sim.Simulator(m)
sim.add_process(deadline_checker)
sim.run()Under Python 3.13.5, this works fine. With Python 3.12.8, I get
Exception ignored in: <coroutine object deadline_checker at 0x7f433c8c9f00>
Traceback (most recent call last):
File "/home/agrif/devel/fpga/simulator_aclose.py", line 7, in deadline_checker
File "/home/agrif/devel/fpga/local/nara-env-312/lib/python3.12/site-packages/amaranth/sim/_async.py", line 414, in repeat
RuntimeError: aclose(): asynchronous generator is already running
While reading #1590, I was confused by why aclose(...) is grumpy, so I dug around. I don't get much from this, but maybe someone else will (or me, later).