我有一个简单的Python uwsgi应用程序,它遵循基本模式:
def application(env, start_response):
... do something ...
... create some threads ...
... handover the work to the threads ...
start_response('200 OK', [('Content-Type','text/html')])
return result
我的系统管理员抱怨我的应用程序没有处理关机,每次他想重启uwsgi服务时,他必须等待uwsgi的超时才能终止应用程序进程。显然,这可能需要30秒,即服务不可用的时间。
是否有特定的信号或电话,uwsgi要关闭它时发送应用程序?我该如何处理?
答案 0 :(得分:1)
def goodbye():
print "Goodbye from worker %d" % uwsgi.worker_id()
uwsgi.atexit = goodbye