django - Run a python script independently when a method is called -


i writing django application need call python script, foo.py when method bar called. script foo.py can take lot of time execute iterates on millions of rows in database. why don't want wait output, want file executed purely os. have tried:

execfile os.system subprocess.popen subprocess.call 

but wait file produce output. how can achieve this? there module missing or can write "observer script" observes if bar method called, run foo.py file independently without , let method finish execution instead of waiting.

probably, did incorrect, because pure subprocess.popen doesn't wait end of child process...

just tried following example:

bar.py:

import subprocess  subprocess.popen(['python', 'foo.py']) print '123' 

foo.py:

import time  time.sleep(50) 

run bar.py:

and see "123" output , see "python" in processes list


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -