Run code at Pyramid shutdown

不羁的心 提交于 2019-12-23 04:38:12

问题


Pyramid supports an ApplicationCreated event. However I can't find any ApplicationDestroyed/ApplicationShutdown event. Is it at all possible do execute a function upon shutdown.

Do I have any choice other than to go further up my stack: ie. I'm using gevent inside uWSGI. It might be possible to get gevent or uWSGI to run my shutdown code, but it certainly isn't as pretty.


回答1:


Pyramid does not support any shutdown event.

However Python has a atexit event, that runs on interpreter shutdown

http://docs.python.org/library/atexit.html

import atexit

@atexit.register
def goodbye():
    print "You are now leaving the Python sector."


来源:https://stackoverflow.com/questions/7484366/run-code-at-pyramid-shutdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!