By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,716 Members | 1,306 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,716 IT Pros & Developers. It's quick & easy.

Handling extended script execution times

P: n/a
A couple of questions:

(1) I have some PHP code that may take a while to execute - say 30-45
seconds or more - and I'm concerned that a browser may give up, and
report an error because a page is not returned within a certain amount
of time. How can I handle this?

Should my PHP script (that generates the webpage) call another PHP
script to do the long-processing task, allowing it to exit earlier
(with a generated webpage), or what?

(2) (a) I'm interested to know how some of these travel sites (Orbitz,
Priceline etc.) can go off and do a search, that sometimes goes on for
a while.

(b) And sometimes I've noticed these types of pages will refresh,
saying things like "Hang on in there... we're still searching."

Does anybody have any advice regarding these questions, or pointers to
more information?

Thanks in advance, Simon.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
SimonC wrote:
A couple of questions:

(1) I have some PHP code that may take a while to execute - say 30-45
seconds or more - and I'm concerned that a browser may give up, and
report an error because a page is not returned within a certain amount
of time. How can I handle this?

Should my PHP script (that generates the webpage) call another PHP
script to do the long-processing task, allowing it to exit earlier
(with a generated webpage), or what?

(2) (a) I'm interested to know how some of these travel sites (Orbitz,
Priceline etc.) can go off and do a search, that sometimes goes on for
a while.

(b) And sometimes I've noticed these types of pages will refresh,
saying things like "Hang on in there... we're still searching."

Does anybody have any advice regarding these questions, or pointers to
more information?


see the php manual for ignore_user_abort() and set_time_limit().

If you want to use PHP to control a backend process ... that's another can
of worms. PHP provides sockets and shared memory functions....but if you
want to run the process on demand (and don't want to use [x]inetd) you'll
need to dissociate the spawned job from the current process group (if
you're using Unix) - I use 'at now ...' for this.

HTH

C.
Jul 17 '05 #2

P: n/a
"Colin McKinnon1" wrote:
SimonC wrote:
A couple of questions:

(1) I have some PHP code that may take a while to execute -

say 30-45
seconds or more - and I'm concerned that a browser may give

up, and
report an error because a page is not returned within a

certain amount
of time. How can I handle this?

Should my PHP script (that generates the webpage) call

another PHP
script to do the long-processing task, allowing it to exit

earlier
(with a generated webpage), or what?

(2) (a) I'm interested to know how some of these travel

sites (Orbitz,
Priceline etc.) can go off and do a search, that sometimes

goes on for
a while.

(b) And sometimes I've noticed these types of pages will

refresh,
saying things like "Hang on in there... we're still

searching."

Does anybody have any advice regarding these questions, or

pointers to
more information?


see the php manual for ignore_user_abort() and
set_time_limit().

If you want to use PHP to control a backend process ... that's
another can
of worms. PHP provides sockets and shared memory
functions....but if you
want to run the process on demand (and don't want to use
[x]inetd) you'll
need to dissociate the spawned job from the current process
group (if
you're using Unix) - I use 'at now ...' for this.

HTH

C.


If you want to use php for a backend process, then execute php from
command line (CLI). That is the reliable way of doing batch/backend
processing. If you are doing a front-end process, like travel sites
having you wait for the query, that is another subject, and I hope
others can answer.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Handling...ict160356.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=539439
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.