def main(...):<br> build_id = create_build_id(...)<br> build_stuff<br> return build_id<br><br>Suppose build_stuff compiles a C program. It could take days to finish, and notify users their builds are ready. I was thinking about using mutliprocessing to handle the build_stuff.<br>
<br>So here is a sample:<br><br>#!/usr/bin/python<br><br>import multiprocessing as mp<br>import time<br><br>def build():<br> print 'I am building HUGE things'<br> time.sleep(10)<br><br>def main():<br> build_p = mp.Process(name='build process', target=build)<br>
build_p.start()<br> return 'abcd12345'<br><br>if __name__ == '__main__':<br><br> v = main()<br> print v<br> print 'done'<br><br>Here is output:<br>yeukhon@fermat:~$ python c2.py<br>
abcd12345<br>done [now hangs for 10 seconds]<br>I build things<br><br>When I looked at `ps -elf|grep python`, I can see two processes running, and one of the python c2.py process is `wait`. But this is not ideal, especially this is a web app. I can't implement any advanced queue / event system right now (I use Pylon, I believe I have gevent installed). But just with multiprocessing, is it possible to send the id first, while running child in the backgroud?<br>
<br>Right now it hangs there as long as the child process is alive. Any solutions?<br><br>Thanks.<br><br><br>