Open snakelab opened 6 years ago
Got it: I have to add:
from state_machine import *
I have the same problem but adding 'from state_machine import ' didn't help me ` from state_machine import @acts_as_state_machine class Process: created = State(initial=True) running = State() terminated = State()
run = Event(from_states=created, to_state=running)
terminate = Event(from_states=running, to_state=terminated)
def __init__(self, name):
self.name = name
@after('run') def run_info(self): print(f'{self.name} is running')
@before('terminate') def terminate_info(self): print(f'{self.name} terminated')
if name == 'main':
p = Process('Test')
p.current_state
p.run()
p.terminate()`
Hi,
first thanks for sharing your code!
I get an error at running the example code:
Traceback (most recent call last): File "./state_state_machine.py", line 7, in <module> @acts_as_state_machine NameError: name 'acts_as_state_machine' is not defined
Any idea what is the problem?
thanks