如何处理正常关闭在Python uwsgi应用(How to handle graceful shu

2019-10-21 00:09发布

我有一个简单的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发送,当它想将其关闭的应用程序? 我该如何处理这个问题?

Answer 1:

def goodbye():
    print "Goodbye from worker %d" % uwsgi.worker_id()

uwsgi.atexit = goodbye

还是这个标准Python模块



文章来源: How to handle graceful shutdown in Python uwsgi application
标签: python uwsgi