1
我已经绘制出了一个流程图,我想遵循,但无法弄清楚如何执行此操作。目前我有以下几点。重新启动Python中的线程并检查异常
t1是一个数据库插入脚本,不是cherrypy。
def main():
thread = ThreadUrl(queue)
thread = thread()
thread.start()
cherrypy.config.update({'server.socket_host': '0.0.0.0',
'server.socket_port': 2970})
#'server.thread_pool': 100})
queue.join()
cherrypy.engine.start()
while True:
if thread.isAlive():
try:
cherrypy.engine.start()
except Exception:
print ('Started cherrypy already.')
print ('I am alive.')
else:
try:
thread.exit()
except Exception:
print ('Already killed this thread.')
print ('I am dead.')
try:
cherrypy.engine.stop()
except Exception:
print ('Already stopped cherrypy.')
try:
thread.start()
except Exception:
print (sys.exc_info()[1])
if __name__ == '__main__':
main()
这似乎......有点令人费解,因为'cherrypy.engine'已经实现了自己的状态机,并且只有在调用'cherrypy.engine.block()'时才会阻塞调用线程。你想用包装线完成什么? – fumanchu 2012-07-11 19:55:01
嗨,对不起,我忘了在描述中添加一行有点重要,t1是一个数据库插入脚本不cherrypy。 – 2012-07-11 21:20:44