开发者

How to run code on Pylons startup

开发者 https://www.devze.com 2022-12-10 11:22 出处:网络
I have a Python 2.6 web app built on Pylons 0.9.7. The code in my controller only runs the first time a client requests it, which is fair enough, but is there any way I can run some code as soon as th

I have a Python 2.6 web app built on Pylons 0.9.7. The code in my controller only runs the first time a client requests it, which is fair enough, but is there any way I can run some code as soon as the server starts 开发者_C百科and is ready to accept requests, without waiting until a request is actually received?


It's an environment setting, if that's what you're asking.

Specifically: lib/app_globals, modify _ _ init _ _ (). (Ignore the spaces there, silly emboldening function!)

See: http://pylonshq.com/docs/en/0.9.7/configuration/#environment

Alternative methods are getting your helper script (that which is launching the server) to run it prior to running the site.

0

精彩评论

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