Python Forum

Full Version: AJAX: readyState not as expected
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm writing a small application implemented using AJAX. Most of it works. The xgttp object calls a python script which terminates having responded with data.

In one case, the Python script creates a sub process which needs to run in background playing a midi file. The parent process terminates but the readyStatus sticks at 1 until the child process terminates. This is strange, as I've verified that the parent process has terminated and the child is still running and has been inherited by init. But Netstat is still showing the http connection as Established.

The child process is called with:
subprocess.Popen(["/home/pi/staticisor/", "-p"    , "%s/%s.mid" % (songdir, song)], close_fds=True)
How can I arrange for the readyStatus to progress to 4 as soon as the parent process dies?

Regards - Philip
Do you .wait() for the popen object to finish?  Or do you spawn the separate process and immediately try to end the program?
Do you .communicate() with the popen object?  I'm just trying to find out if there's anything you're doing that'd hang the parent program so that it'd wait for the child to finish.
Thank you Nilamo, but as I said, I've verified that the parent process has terminated. A series of ps listings shows the parent process disappearing and the child continuing, now with init as its parent. Also, netstat shows the http connection remaining open. I don't want to .wait() or .communicate() with the Popen object - I just want to complete the xhttp request leaving the the child to run its course.

I thought the Popen close_fds parameter should have prevented the socket file descriptor being passed to the child, which should have caused it to be closed when the parent dies.