Re: subprocess & redirect

"Jonathan Ellis" <[email protected]>
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
Did you try using the native spyce server?  It should work fine there. 
I wouldn't be surprised if mod_python or something else is screwing with
you.

On Mon, 20 Mar 2006 16:14:29 -0500, "Philip Semanchuk"
<[email protected]> said:
> Hi all,
> I'm trying to spawn a subprocess in response to a form submission and 
> it isn't behaving as I'd like. The subprocess will run for a long time 
> (minutes or hours, possibly even days) and so I want to spawn it 
> *asynchronously* and then immediately redirect the user to a page that 
> says "Your job has been started, go get a cup of coffee" etc. However, 
> the redirect doesn't occur until the spawned process completes.
> 
> There's an example below. In the example, foo.py is just a stub that 
> calls time.sleep(10). I tried spawning foo.py using the subprocess 
> module (from Python 2.4) and also using os.spawnl(os.P_NOWAIT...). The 
> two should be equivalent, and indeed neither gives me asynchronous 
> execution although I expect that both would. They spawn an asynchronous 
> process when called outside of the context of Spyce, so there's some 
> interaction here that I don't understand. Can anyone enlighten me? I'd 
> appreciate it.
> 
> Thanks
> Philip
> 
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
> "http://www.w3.org/TR/html4/strict.dtd">
> <html lang="en">
> <head>
> 	<meta http-equiv="content-type" content="text/html; charset=utf-8">
> 	<title>test</title>
> </head>
> <body>
> 
> <p>redirect test</p>
> 
> [[.import name=redirect]]
> 
> [[\
>      import subprocess
>      import os
> 
>      TheLongRunningProcess = "/usr/local/MyStuff/src/foo.py"
> 
>      subprocess.Popen(["python", TheLongRunningProcess])
> 
>      #os.spawnl(os.P_NOWAIT, "/usr/bin/python", "/usr/bin/python", 
> TheLongRunningProcess)
> 
>      redirect.external("http://google.com")
> 
>      # This doesn't make a difference
>      raise spyceDone
> 
> ]]
> 
> </body>
> </html>
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Spyce-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spyce-users
-- 
C++ is history repeated as tragedy. Java is history repeated as farce.  --Scott McKay



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.