Actually i will give input from my application1 to input.txt, which intern triggers {used pyinotify} program1 to run this program1 which updates output.txt file, but application1 which is reading from output.txt doesn't wait for program1 to complete the writing process on the text file(output.txt), It reads the old data from output.txt. I need Application1 to wait for the completion of program1's process how can i do this??
import pyinotify,subprocess
def onChange(ev):
cmd = ['/usr/bin/env', 'python','/var/www/cgi-bin/version2_1.py', ev.pathname]
subprocess.Popen(cmd).communicate()
wm = pyinotify.WatchManager()
wm.add_watch('/var/www/cgi-bin/input.txt', pyinotify.IN_CLOSE_WRITE, onChange)
notifier = pyinotify.Notifier(wm)
notifier.loop()
This is the program that i have used to run my python program1 on the background on trigger to input text, right after this trigger the application1's execute this statement out_file=open("/var/www/cgi-bin/output.txt", "r").read()
Now application1 takes content of output before it's updated by program1!! I want Aplication1 to wait for the program1 to complete its run and updatition over output.txt
pls give me an idea how can i go about this..
Thank you :)