Pyramid 支持 ApplicationCreated
事件。但是我找不到任何 ApplicationDestroyed
/ApplicationShutdown
事件。是否有可能在关闭时执行某个功能。
除了进一步提升我的堆栈之外,我还有其他选择吗:即。我在uWSGI 中使用gevent。也许可以让 gevent 或 uWSGI 来运行我的关闭代码,但它肯定不是那么漂亮。
最佳答案
Pyramid 不支持任何关闭事件。
然而,Python 有一个 atexit
事件,该事件在解释器关闭时运行
http://docs.python.org/library/atexit.html
import atexit
@atexit.register
def goodbye():
print "You are now leaving the Python sector."
关于python - 在 Pyramid 关闭时运行代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7484366/