admin 管理员组

文章数量: 1184232


2024年1月18日发(作者:maven的特点)

'''Created on Oct 27, 2015@author: wujz'''import threading,traceback,sysclass runScriptThread(): #The timer class is derived from the class def __init__(self, funcName, *args): .__init__(self) = args me = funcName de = 0 ion = None _traceback = ''

def run(self): #Overwrite run() method, put what you want the thread do here try: self._run() except Exception as e: de = 1 # 如果线程异常退出,将该标志位设置为1,正常退出为0 ion = e _traceback = ''.join(_exception(*_info())) #在改成员变量中记录异常信息

def _run(self): try: me(*())

except Exception as e: raise e

改写后的主线程:import runScriptThread,tracebackif __name__=='__main__': sth = 'hello world' try: aChildThread = runScriptThread(printSth, sth) () ()

except Exception as e: print(_traceback)


本文标签: 退出 标志 记录 变量 特点