-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
|
||
### Issue 480 | ||
|
||
A StateMachine that exercises the example given on issue | ||
#[480](https://github.com/fgmacedo/python-statemachine/issues/480). | ||
|
||
Should be possible to trigger an event on the initial state activation handler. | ||
|
||
```py | ||
>>> from statemachine import StateMachine, State | ||
>>> | ||
>>> class MyStateMachine(StateMachine): | ||
... State_1 = State(initial=True) | ||
... State_2 = State() | ||
... Trans_1 = State_1.to(State_2) | ||
... | ||
... def __init__(self): | ||
... super(MyStateMachine, self).__init__() | ||
... | ||
... def on_enter_State_1(self): | ||
... print("Entering State_1 state") | ||
... self.long_running_task() | ||
... | ||
... def on_exit_State_1(self): | ||
... print("Exiting State_1 state") | ||
... | ||
... def on_enter_State_2(self): | ||
... print("Entering State_2 state") | ||
... | ||
... def long_running_task(self): | ||
... print("long running task process started") | ||
... self.Trans_1() | ||
... print("long running task process ended") | ||
... | ||
>>> sm = MyStateMachine() | ||
Entering State_1 state | ||
long running task process started | ||
long running task process ended | ||
Exiting State_1 state | ||
Entering State_2 state | ||
|
||
``` |