重启已终止的流程实例 [英] Restart terminated process instance
本文介绍了重启已终止的流程实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!我有一个变量,我用它来执行另一个模块的方法。问题是,当它终止时......我无法再次启动它。是否有可能重新启动 - 刷新或类似的东西,这个类的实例?下面是我的应用程序的示例代码:
Hi! I have a variable, that i use to execute a method from another module. The thing is, that when it's terminated... i cannot start it again. Is it possible to restart-refresh or something similar, the instance of this class ? Here is a sample code of what my application looks like:
ProcessVariable = Process(target=modulename.methodname)
while(True):
command = raw_input("Enter an command: ")
if(command == "start_the_process"):
ProcessVariable.start()
if(command == "stop_the_process")
ProcessVariable.terminate()
#there are otherother commands ofcourse
#this stacture cannot be changed at any manner.
我拥有什么尝试过:
我认为,作为极端极端的解决方案,我要创建一个实例列表,每次都使用不同的实例...但这不是一个好的解决方案......原因很明显......
What I have tried:
One thinng i though, as an extremely extreme solution, is to create a list of instances, and everytime use a different one... but this is not a good solution... for obvious reasons...
推荐答案
我找到了一个解决方案。我创建了一个列表,我可以在其中创建新对象,然后使用它们。当我不再想要它们时......我从列表中删除它们。
I found a solution. I created a list, where i was able to create new object, then use them. When i didn't want them anymore... i delete them from the list.
这篇关于重启已终止的流程实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文