开发者

How expensive it is to load the environment to run a Python script?

I have a background python script that gets ran several thousand times a day. I'm simply running it with python foo.py. The script itself does some imports (a parsing library and sqlalchemy) and then makes a database connection, makes the parsing and saves the data to db.

I'm wondering if it adds a lot of overhead to load the python environment eac开发者_如何学Goh time the script is run?

I could make it so that the script is started once and it would have a polling loop to see if it should do something, but want to clarify that it's worth to do this.

Any input?


of course it adds a lot of overhead, and it would be (however negligibly) more eco-friendly to use a built-in poll or select(); but then you'd have to have a watchdog to see if it crashed, or use respawn from inittab. as long as the server load is fine, it might not be worth the effort.


forgot to mention, memory leaks that would be unnoticeable in a cron job can become server-eating monsters when your script runs as a daemon. you'd want to watch it carefully the first hour or two, to see if it's growing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜