0

I am using python daemon to check a particular table in mongodb if there is any value it should call another python script. Below is the code what I am trying, but it doesn't call the script. can somebody help me out:

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()
Abhilash Kumar
  • 211
  • 1
  • 9

1 Answers1

1

yes i got it. Am posting as it may be it helps someone

Instead of using

os.system(path)

Use:

subprocess.call(['python', '/Path_from_root_directory/XYZ.py', ids]) // ids is my argument to be passed
Abhilash Kumar
  • 211
  • 1
  • 9