Skip to content

Async: an exception in the macrostep after the lock holder's own event is silently lost #689

Closed

Description

@fgmacedo

On the async engine with catch_errors_as_events=False (the StateMachine default), when the lock holder's own event succeeds but a later microstep of the same macrostep raises (an internal event or an eventless transition), await send() returns the event's result and the exception is lost: no caller sees it and nothing is logged. The sync engine raises it to the caller of send().

class M(StateMachine):
    a = State(initial=True); b = State(); c = State()
    go = a.to(b); boom = b.to(c); back = c.to(a)
    def on_go(self): return "went"
    async def on_enter_b(self): await self.raise_("boom")
    async def on_boom(self): raise ValueError("kaboom")
  • Sync (same chart with sync callbacks): sm.send("go") raises ValueError: kaboom.
  • Async: await sm.send("go") returns "went", the machine stays in b, and the ValueError is not raised anywhere.

Reported as pre-existing on v3.2.1 in #688. Expected: the exception reaches the caller whose send() started the macrostep, as on the sync engine.

Activity

  1. added this to the 3.2.2 milestone on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions