On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat <thibaud.roussil...@gmail.com> wrote: > Hi, > > I work with Python 2.4 and CGI. > > I have a CGI which call a Python script in background process and return > result before background task is finished. > > Actually, the browser displays response but it is waiting for end of > background task because the socket is not closed. > > Internet told me that I must close the stdout file descriptor > (sys.stdout.close()) to close the socket but it doesn't work. > > The background task is launched via subprocess.Popen and is attached to the > root process on ps command. >
This means that the parent process finished before the child. Call wait() on the Popen object to wait for the child to terminate. Depending on how you create the Popen object, the child process may inherit your own stdout. In that case, the child process may be keeping the socket open after the parent dies. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list