473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

cgi and popen

A long story made short, I've build a python/cgi website consisting of
two pages. Page1 has a html form in which you can input a series of
queries. Then via Popen it starts a pythons search script, which stores
the results in a python shelve.
As the Popen command is given it should redirect to page2, which will
check if the shelve is ready (search finished) and if not displays a
search page, refreshing itself after 10 seconds.
The Popen command works nice when tried out in the console. The script
isueing the Popen quits, and the other process keeps on running till
finished.
But when embedded in page1.cgi, page 1 waits till the search is
finished, resulting in a browser timeout when big queries are done. It
was this problem in the first place why I split up the page in two and
added Popen.
Does anybody know how to get the page not waiting on Popen to finish?

thnx
Maarten
Jun 7 '06 #1
2 2842
Am Wed, 07 Jun 2006 14:54:41 +0200 schrieb Maarten van Veen:
A long story made short, I've build a python/cgi website consisting of
two pages. Page1 has a html form in which you can input a series of
queries. Then via Popen it starts a pythons search script, which stores
the results in a python shelve.
As the Popen command is given it should redirect to page2, which will
check if the shelve is ready (search finished) and if not displays a
search page, refreshing itself after 10 seconds.
The Popen command works nice when tried out in the console. The script
isueing the Popen quits, and the other process keeps on running till
finished.


Hi,

You can find out where the process hangs, by
sending SIGINT to the python script:

kill -SIGINT PID

This is like ctrl-c, you should get a traceback.

If the page1 script is not alive anymore, during
the unwanted waiting, this does not work.

Which form of popen do you use? Popen4 is the best,
because you cannot get a deadlock if there is output
on stdout and stderr.

I guess you have the same strange thing, if you
ssh to the server, start the script1 and you want
to logoff before the subprocesses is finished.

You can try to start the script like this:

nohup nice mein-script >> $HOME/log/mein-script.log 2>&1 </dev/null &

HTH,
Thomas

--
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: ni**************@thomas-guettler.de

Jun 7 '06 #2
In article <pa****************************@thomas-guettler.de>,
Thomas Guettler <ni**************@thomas-guettler.de> wrote:
Am Wed, 07 Jun 2006 14:54:41 +0200 schrieb Maarten van Veen:
A long story made short, I've build a python/cgi website consisting of
two pages. Page1 has a html form in which you can input a series of
queries. Then via Popen it starts a pythons search script, which stores
the results in a python shelve.
As the Popen command is given it should redirect to page2, which will
check if the shelve is ready (search finished) and if not displays a
search page, refreshing itself after 10 seconds.
The Popen command works nice when tried out in the console. The script
isueing the Popen quits, and the other process keeps on running till
finished.


Hi,

You can find out where the process hangs, by
sending SIGINT to the python script:

kill -SIGINT PID

This is like ctrl-c, you should get a traceback.

If the page1 script is not alive anymore, during
the unwanted waiting, this does not work.

Which form of popen do you use? Popen4 is the best,
because you cannot get a deadlock if there is output
on stdout and stderr.

I guess you have the same strange thing, if you
ssh to the server, start the script1 and you want
to logoff before the subprocesses is finished.

You can try to start the script like this:

nohup nice mein-script >> $HOME/log/mein-script.log 2>&1 </dev/null &

HTH,
Thomas


Thx for your reply Thomas. I use subprocess.Popen, because popen 1t/m 4
are deprecated.
I found a dodgy way around my problem though. By inserting another page
between the input and the results page,a user sees a "i'm searching"
page which wants to redirect to the results page directly, but keeps
waiting for the search process to finish.
So I put what used to be my problem to good use. :D

Maarten
Jun 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sami Viitanen | last post by:
Hello, I was using os.popen function to get CVS command output to string from script.. Same commands worked well with Windows, but Linux seems to have problem with those. Whole CVS commands...
2
by: Stuart McGraw | last post by:
When I run (Python 2.3.3) this script on a MS Windows 2000 machine: import os print "1st popen..." f = os.popen ("echo " + u"\u0054\u0045\u0053\u0054.txt") print f.read () print "2nd popen..."...
17
by: bastiaannaber | last post by:
I am trying to write a program which uses popen but I have a problem. I want to detect if the program I call with popen has ended. For example: #include <stdio.h> #include <sys/types.h>...
2
by: Greg Ercolano | last post by:
When I use os.popen(cmd,'w'), I find that under windows, the stdout of the child process disappears, instead of appearing in the DOS window the script is invoked from. eg: C:\type foo.py import...
3
by: Jesse | last post by:
Hi all, I have a problem using wget and Popen. I hope someone can help. -- Problem -- I want to use the command: wget -nv -O "dir/cpan.txt" "http://search.cpan.org" and capture all it's...
12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
15
by: Daniel Klein | last post by:
I'm trying to get popen to work on Windows. Here's a simplified example of what I'm trying to get working: I have a hw.c program as follows: #include <stdio.h> main() { printf ("Hello...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.