我在Ubuntu 服务器上使用这个配方: http ://code.activestate.com/recipes/278731/。
我制作了一个这样的守护进程实例:
class MyDaemon(Daemon):
def run(self):
while True:
try:
do_my_data_processing()
except MySQLdb.OperationalError:
# Sleep an extra 30 seconds if database is away.
time.sleep(30)
time.sleep(30)
问题是即使在休眠时,守护进程也会占用几乎所有可用的 CPU 资源。
我究竟做错了什么?