Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX: readyState not as expected
#1
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/stat.py", "-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
Reply
#2
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.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Retrieve data from ajax pthon3 0 1,159 May-29-2022, 10:32 PM
Last Post: pthon3
  POST Reply to Ajax/jQuery (mostly an HTML question) gw1500se 5 2,606 Nov-18-2021, 02:44 PM
Last Post: gw1500se
  Scraping a dynamic data-table in python through AJAX request filozofo 1 3,823 Aug-14-2020, 10:13 AM
Last Post: kashcode
  Flask SelectField using Ajax noah_f 0 2,495 Mar-23-2020, 04:03 PM
Last Post: noah_f
  Ajax and Selenium ankitjindalbti 3 3,277 May-31-2019, 03:40 PM
Last Post: ankitjindalbti

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020