判断Threading.start新线程是否执行完

  1. 新写自己的Threading类
class MyThread(threading.Thread):#我的Thread类 判断流程结束没 用于os shell命令是否执行判断
    def __init__(self,func = ""):#输入待执行函数名 我执行的函数没有参数就没有加args输入了
        threading.Thread.__init__(self)
        self.func = func
        self.result = 1#未完成为1 标志位
    # 调用start自动执行的函数
    def run(self):
        self.result = self.func()
        self.result = 0#完成返回0

然后执行

class MyThread(threading.Thread):#我的Thread类 判断流程结束没 用于os shell命令是否执行判断
    def __init__(self,func = ""):#输入待执行函数名 我执行的函数没有参数就没有加args输入了
        threading.Thread.__init__(self)
        self.func = func
        self.result = 1#未完成为1 标志位
    # 调用start自动执行的函数
    def run(self):
        self.result = self.func()
        self.result = 0#完成返回0

这样就可以判断os.sysytem里语句是否执行完成是否

猜你喜欢

转载自blog.csdn.net/cool_bot/article/details/89678392