467,222 Members | 1,447 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,222 developers. It's quick & easy.

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
  • viewed: 2479
Share:
2 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Sami Viitanen | last post: by
2 posts views Thread by Stuart McGraw | last post: by
17 posts views Thread by bastiaannaber@gmail.com | last post: by
2 posts views Thread by Greg Ercolano | last post: by
3 posts views Thread by Jesse | last post: by
12 posts views Thread by Eric_Dexter@msn.com | last post: by
15 posts views Thread by Daniel Klein | last post: by
25 posts views Thread by Jeremy Banks | last post: by
1 post views Thread by Mark Shewfelt | last post: by
reply views Thread by Adict | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.