Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to spawn Python2.5 process through Apache and return immediately under Windows
    text
    copied!<p>I have two Python scripts, one launches the other with subprocess</p> <p>invoke.py:</p> <pre><code>import subprocess p = subprocess.Popen(['python', 'long.py']) print "Content-Type: text/plain\n" print "invoked (%d)" % (p.pid) </code></pre> <p>longtime.py:</p> <pre><code>import time import os print "start (%d)" %(os.getpid()) time.sleep(10) print "end (%d)" %(os.getpid()) </code></pre> <p>When I execute invoke.py from shell it returns immediately and longtime.py works in background (works on Windows and Linux). If I call invoke.py through Web Interface (Apache CGI) it works under Linux <strong>but not on Windows</strong> machine, there the website gets stuck and only returns after longtime.py has finished.</p> <p>How can I configure Python subprocess or Apache to get the same behavior under Windows? Whats the difference?</p> <p>Maybe the Apache config on Windows is somehow different but i didnt find something.</p> <p>Linux: Debian, Python2.5.2, Apache2.2.9<br> Windows: WinXP, Python2.7, Apache2.2.17</p> <p>Maybe you have also a better design approach (because its a little awkward how I do it now).</p> <p>What for?: I have a script on the webserver which takes quite a long time to calculate (longtime.py). I want to activate the execution via web interface. The Website should return immediatly and longtime.py should work in background and writes output in a file. Later a request from web interface checks if the file is generated and reads the output. I can not use common cloud-provider as they dont support multithreading. Also I can not install a daemon handler on the webserver because processes have a maximum runtime.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload