2011-09-20 55 views
1

金字塔支持ApplicationCreated事件。但是我找不到任何ApplicationDestroyed/ApplicationShutdown事件。完全可能在关机后执行一个功能。金字塔停机时运行代码

除了进一步了解我的堆栈之外,我还有其他选择吗?我在uWSGI里面使用gevent。可能有gevent或uWSGI来运行我的关闭代码,但它肯定不是很漂亮。

回答

2

金字塔不支持任何关机事件。

但是Python有一个atexit事件,那就解释关机运行

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

import atexit 

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