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
class Config:
guard_with = statesman.Guard.silence
For example, the following code throws RuntimeError: event trigger failed: the "run" event cannot be triggered from the current state of "stopped"
when I try to call run in stopped state. I would like to silently continue, but not execute the state if it is illegal.
Or how to use this state machine in a user interaction, when the user may send commands which are not yet allowed?
import statesman
import asyncio
class StateMachine(statesman.StateMachine):
class States(statesman.StateEnum):
waiting = 'Waiting'
running = 'Running'
stopped = 'Stopped'
aborted = 'Aborted'
class Config:
guard_with = statesman.Guard.silence
@statesman.event(None, States.waiting)
async def start(self) -> None:
...
@statesman.event(States.waiting, States.running)
async def run(self) -> None:
...
@statesman.event(States.running, States.stopped)
async def stop(self) -> None:
...
@statesman.event(States.__any__, States.aborted)
async def abort(self) -> None:
...
@statesman.event(
States.__any__,
States.__active__,
type=statesman.Transition.Types.self
)
async def check(self) -> None:
print("Exiting and reentering active state!")
async def _example() -> None:
state_machine = await StateMachine.create()
await state_machine.start()
await state_machine.run()
await state_machine.stop()
# I would like to silently keep the last state for the following
await state_machine.run()
if __name__ == '__main__':
asyncio.run(_example())
The text was updated successfully, but these errors were encountered:
tiborkiss
changed the title
guard_with = Guard.silence doesn't seem to work for m
guard_with = Guard.silence doesn't seem to work for me
Mar 26, 2021
I don't understand how to work with
For example, the following code throws
RuntimeError: event trigger failed: the "run" event cannot be triggered from the current state of "stopped"
when I try to call run in stopped state. I would like to silently continue, but not execute the state if it is illegal.
Or how to use this state machine in a user interaction, when the user may send commands which are not yet allowed?
The text was updated successfully, but these errors were encountered: