python模拟进程状态

代码内容

class Matter(object):
    pass
model=Matter
states=['New','Ready','Waiting','Running','Terminated']
transitions=[
    {'trigger':'Admitted','source':'New','dest': 'Ready' },
    {'trigger':'Dispatch','source':'Ready','dest': 'Running'},
    {'trigger':'Interrupt','source':'Running','dest': 'Ready'},
    {'trigger':'Input or event completion','source':'Waiting','dest': 'Ready'},
    {'trigger':'Output or event completion','source':'Waiting','dest': 'Ready'},
    {'trigger':'Input or event wait','source':'Running','dest': 'Waiting'},
    {'trigger':'Output or event wait','source':'Running','dest': 'Waiting'},
    {'trigger':'Exit','source':'Running','dest': 'Terminated'}]
machine = Machine(model=model, states=states, transitions=transitions, initial='New')
print(model.state)
model.Admitted()
print(model.state)
model.Dispatch()
print(model.state)
model.Exit()
print(model.state)

代码运行结果截图:

python模拟进程状态

上一篇:Source insight4安装,简单易学,上手快


下一篇:Python模拟进程状态