SHORT VERSION:
Python File B changes sys.stdout to a file so all 'prints' are written
to the file. Python file A launches python file B with os.popen("./B
2>&^1 >dev/null &"). Python B's output disappears into never-never
land.
LONG VERSION:
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 the cgi end, all I want my (python) cgi script to do is check for
form errors, make sure the server isn't crushed, run the simulation
and redirect to a loading page (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 3 2164
On Mon, Jan 29, 2007 at 03:12:37PM -0800, Pappy wrote:
SHORT VERSION:
Python File B changes sys.stdout to a file so all 'prints' are written
to the file. Python file A launches python file B with os.popen("./B
2>&^1 >dev/null &"). Python B's output disappears into never-never
land.
LONG VERSION:
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 the cgi end, all I want my (python) cgi script to do is check for
form errors, make sure the server isn't crushed, run the simulation
and redirect to a loading page (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?
The subprocess module is probably a good starting point: http://docs.python.org/dev/lib/module-subprocess.html
It will allow you greater control over what happens with the output of a
process that you start. Specifically look at the the stdout and stderr
arguments to Popen. You can provide these with an open file descriptor or a
file object and it will dump the output into there.
-Chris
>
_jason
-- http://mail.python.org/mailman/listinfo/python-list
On Tue, Jan 30, 2007 at 10:42:22AM -0500, Jason Persampieri wrote:
Sadly, the group is tied to Python 2.3 for now.
Subprocess for 2.2 and 2.3: http://www.lysator.liu.se/~astrand/popen5/
Win32 installers for subversion for 2.2 and 2.3: http://www.lysator.liu.se/~astrand/popen5/
-Chris
>
Actually, I got around this problem by using an intermediate process that
happens to handle output on its own (bsub).
On 1/30/07, Chris Lambacher <[1]ch***@kateandchris.netwrote:
The subprocess module is probably a good starting point:
[2]http://docs.python.org/dev/lib/module-subprocess.html
It will allow you greater control over what happens with the output of a
process that you start. Specifically look at the the stdout and stderr
arguments to Popen. You can provide these with an open file descriptor
or a
file object and it will dump the output into there.
-Chris
>
_jason
>
--
[3]http://mail.python.org/mailman/listinfo/python-list
References
Visible links
1. mailto:ch***@kateandchris.net
2. http://docs.python.org/dev/lib/module-subprocess.html
3. http://mail.python.org/mailman/listinfo/python-list
On Jan 29, 7:12 pm, "Pappy" <helga...@gmail.comwrote:
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.
LONG VERSION:
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
forever?
-Greg This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Osman |
last post by:
Hi,
I'm looking for a javascript function that will convert input such as this:
<CLUB Code="
into this:
<CLUB Code="
|
by: Laermans_k |
last post by:
Hi,
Does anyone have a solution to use the <input type="file"
id="filechooser"> and the <input type="submit" id="submitbutton"> in 1
button click?
I've already tried to create a javascript...
|
by: barney |
last post by:
Hello,
I' m using .NET System.Xml.XmlDOcument.
When I do the following:
XmlDocument xml = new XmlDocument();
xml.Load("blah");
....
xml.Save("blub");
I've got the problem that the following...
|
by: vijay |
last post by:
Hello,
As the subject suggests, I need to print the string in the reverse
order. I made the following program:
# include<stdio.h>
struct llnode
{
char *info;
|
by: Carpe Diem |
last post by:
Hello I have an aspx page that loses Session("user") value after a few
minutes even after I set
<sessionState mode="InProc" cookieless="false" timeout="300"> in web.config
and wrote
function...
|
by: martin |
last post by:
Hi,
I would be extremly grateful for some help on producing an xml fragemt.
The fragment that I wish to produce should look like this
<Addresses>
<Address>&qout;Somebody's Name"...
|
by: andrew007 |
last post by:
I do xml / xslt transformation using asp.net but I found
any value (w/xml format) in xml node html-encoded to < and > format if
it's > or < tag.
Since I have sub xml data in a parent xml node...
|
by: Arne |
last post by:
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as & to be valid. I don't
have Firefox my self and don't wont to install it only...
|
by: kaleshwar |
last post by:
Hello, I want to ask that what is the difference between to define
#include<stdio.h> and
#include" filename.c"
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
| |