python模拟进程状态
2021/11/24 7:10:02
本文主要是介绍python模拟进程状态,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
from transitions import Machine class Progress(object): pass model = Progress() states = ['New', 'Ready', 'Waiting', 'Running', 'Terminated'] transitions = [ {'trigger': 'Admitted', 'source': 'New', 'dest': 'Ready'}, {'trigger': 'Input', 'source': 'Waiting', 'dest': 'Ready'}, {'trigger': 'Output', 'source': 'Waiting', 'dest': 'Ready'}, {'trigger': 'event_completion', 'source': 'Waiting', 'dest': 'Ready'}, {'trigger': 'event_wait', 'source': 'Running', 'dest': 'Waiting'}, {'trigger': 'Input', 'source': 'Running', 'dest': 'Waiting'}, {'trigger': 'Output', 'source': 'Running', 'dest': 'Waiting'}, {'trigger': 'Interrupt', 'source': 'Running', 'dest': 'Ready'}, {'trigger': 'Dispatch', 'source': 'Ready', 'dest': 'Running'}, {'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.event_wait() print(model.state) model.Output() print(model.state) model.Dispatch() print(model.state) model.Exit() print(model.state)
这篇关于python模拟进程状态的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-14Python编程入门指南
- 2024-11-13Python基础教程
- 2024-11-12Python编程基础指南
- 2024-11-12Python基础编程教程
- 2024-11-08Python编程基础与实践示例
- 2024-11-07Python编程基础指南
- 2024-11-06Python编程基础入门指南
- 2024-11-06怎么使用python 计算两个GPS的距离功能-icode9专业技术文章分享
- 2024-11-06Python 基础编程入门教程
- 2024-11-05Python编程基础:变量与类型