printing to a redirected stdout from a process that was called with "2>&1 > /dev/null &"

gregpinero at gregpinero at
Thu Mar 15 20:58:42 CET 2007

On Jan 29, 7:12 pm, "Pappy" <helga... at> wrote:
> SHORT VERSION:PythonFile B changes sys.stdout to a file so all 'prints' are written
> to the file.  Pythonfile A launchespythonfile B with os.popen("./B
> 2>&^1 >dev/null &").  PythonB's output disappears into never-never
> land.
> I am working on a site that can kick off large-scale simulations.  It
> will write the output to an html file and a link will be emailed to
> the user.  Also, the site will continue to display "Loading..." if the
> user wants to stick around.
> The simulation is legacy, and it basically writes its output to stdout
> (via simple print statements).  In order to avoid changing all these
> prints, I simply change sys.stdout before calling the output
> functions.  That works fine.  The whole thing writes to an html file
> all spiffy-like.
> On thecgiend, all I want my (python)cgiscript to do is check for
> form errors, make sure the server isn't crushed, run the simulation
> and redirect to aloadingpage (in detail, I write a constantly
> updating page to the location of the final output file.  When the
> simulation is done, the constantly updating file will be magically
> replaced).  The root problem is that the popen mechanism described
> above is the only way I've found to truly 'Detach' my simulation
> process.  With anything else, Apache (in a *nix environment) sits and
> spins until my simulation is done.  Bah.
> Any ideas?
> _jason

Did you ever find your answer Mr. _jason?  I'm trying to do the same
thing now but even with the subprocess module the broswer still says
loading until the subprocess is done.

Is there truly NO way to kick of a process and be done with it


More information about the Python-list mailing list