开发者

Run code at Pyramid shutdown

开发者 https://www.devze.com 2023-04-05 22:33 出处:网络
Pyramid supports an ApplicationCreated event. However I can\'t find any ApplicationDestroyed/ApplicationShutdown event. Is it at all p开发者_如何学编程ossible do execute a function upon shutdown.

Pyramid supports an ApplicationCreated event. However I can't find any ApplicationDestroyed/ApplicationShutdown event. Is it at all p开发者_如何学编程ossible 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.


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."
0

精彩评论

暂无评论...
验证码 换一张
取 消