Commit aac44fc
committed
feat: invoke callback group — spawn external work from states
Add invoke as a first-class callback group (CallbackGroup.INVOKE), following
SCXML <invoke> semantics. States can spawn background work (API calls, file I/O,
child state machines) on entry and cancel it on exit.
- New CallbackGroup.INVOKE with convention naming (on_invoke_<state>),
decorator (@state.invoke), and inline callables
- IInvoke protocol for advanced handlers with InvokeContext (cancellation,
send events to parent, machine reference)
- StateChartInvoker adapter for child state machine invocation
- invoke_group() for running multiple callables concurrently and waiting
for all results as a single done.invoke event
- InvokeManager lifecycle management integrated into both sync and async engines
(sync: daemon threads, async: thread executor wrapped in asyncio.Task)
- done_invoke_<state> factory prefix maps to done.invoke.<state> event family
- visitor pattern (visit/async_visit) on CallbacksExecutor and CallbacksRegistry
- __contains__ on CallbacksRegistry to avoid direct _registry access
- Full test suite and documentation with practical file I/O examples1 parent 3b5ef35 commit aac44fc
12 files changed
Lines changed: 1480 additions & 6 deletions
File tree
- docs
- releases
- statemachine
- engines
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
0 commit comments