StateMachine 2.3.1
June 7, 2024
What's new in 2.3.1
This release has a high expected feature, we're adding asynchronous support, and enhancing overall functionality. In fact, the approach we took was to go all the way down changing the internals of the library to be fully async, keeping only the current external API as a thin sync/async adapter.
Python compatibility 2.3.1
StateMachine 2.3.1 supports Python 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12.
We've fixed a bug on the package declaration that was preventing users from Python 3.7 to install the latest version.
Asynchronous Support in 2.3.1
This release introduces native coroutine support using asyncio, enabling seamless integration with asynchronous code.
Now you can send and await for events, and also write async Actions, Conditions and Validators.
>>> class AsyncStateMachine(StateMachine):
... initial = State('Initial', initial=True)
... final = State('Final', final=True)
...
... advance = initial.to(final)
>>> async def run_sm():
... sm = AsyncStateMachine()
... await sm.advance()
... print(sm.current_state)
>>> asyncio.run(run_sm())
Final