You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Awaiting ctx.run results from several asyncio tasks loses wakeups: the handler stalls until inactivity_timeout #315
When a handler awaits several durable futures from different asyncio tasks, for example asyncio.gather over tasks that each await ctx.run_typed(...), the handler regularly hangs. All run results are proposed, acknowledged by the runtime, and delivered to the SDK. Even so, one task stays blocked until the service's inactivity_timeout (60 s by default) ends the attempt. The retry replays the journal and finishes, so the invocation succeeds, but it pays the full timeout each time.
The cause is that every waiting task runs its own create_poll_or_cancel_coroutine loop, and all of those loops read from the one ReceiveChannel queue. The runtime's completion for task A's handle can be read by task B. B feeds it to the VM, checks only its own handle, and goes back to receive(). Nobody re-checks A, so A sleeps until the next input frame, which never comes.
restate.gather(...) over the same futures, awaited from one task, is not affected.
importasyncioimportrandomimportrestatesvc=restate.Service("Repro")
@svc.handler()asyncdefrun(ctx: restate.Context, n: int) ->str:
# Await n ctx.run results from separate asyncio tasks, as pydantic-ai does for parallel tool calls.asyncdefstep(i: int) ->str:
asyncdefwork() ->str:
awaitasyncio.sleep(random.uniform(0.001, 0.05))
returnstr(i)
returnawaitctx.run_typed(f"step {i}", work)
for_inrange(3):
awaitasyncio.gather(*(asyncio.create_task(step(i)) foriinrange(n)))
return"ok"app=restate.app(services=[svc])
docker run -d --name restate --network host docker.restate.dev/restatedev/restate:1.8.0
hypercorn repro:app --bind 127.0.0.1:9080
curl localhost:9070/deployments -H content-type:application/json -d '{"uri":"http://127.0.0.1:9080"}'
curl -X PATCH localhost:9070/services/Repro -H content-type:application/json -d '{"inactivity_timeout":"5s"}'fornin 1 3;do
seq 1 40 | xargs -P 10 -I{} curl -s -o /dev/null -w '%{time_total}\n' \
localhost:8080/Repro/run -H content-type:application/json -d $n \
| awk -v n=$n'{t++; if ($1>4) s++} END {print "n=" n ": " s "/" t " took >4s"}'done
We hit this at Workato too, running pydantic-ai agents with parallel tool calls on Restate. I've opened #325 with a fix: a single input reader, which wakes the other pollers after each event. Feedback welcome.
Activity
kirillsergeev-workato commentedon Nov 24, 2026
We hit this at Workato too, running pydantic-ai agents with parallel tool calls on Restate. I've opened #325 with a fix: a single input reader, which wakes the other pollers after each event. Feedback welcome.