我正在使用 python 守护程序检查 mongodb 中的特定表,如果有任何值它应该调用另一个 python 脚本。下面是我正在尝试的代码,但它不调用脚本。有人可以帮我吗:
import daemon
import time
import os
from pymongo import MongoClient
connection = MongoClient(IPADDRESS, PORT)
monitor_db = connection.testmongo.XYZ_monitoring
def interval_monitoring():
while True:
searchForm = monitor_db.find()
for user in searchForm:
user_id=user['user_id']
for ids in user_id:
path= "python XYZ.py "+ids
os.system(path)
time.sleep(60)
def run():
print daemon.__file__
with daemon.DaemonContext():
interval_monitoring()
if __name__ == "__main__":
run()