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