Reply to Re: How to properly handle lengthy operations?

Your name:

Reply:


Posted by mootmail-googlegroups on 09/12/06 12:22

Jonah Bishop wrote:
> Are there programming paradigms that work well for situations like
> this? What tips do people here have for such a situation? Any help
> would be greatly appreciated! Thanks.

If this is a process that takes long enough to timeout the default
script execution limit, then it is probably way too long for an
end-user to sit and wait for, so simply increasing the timeout should
NOT be an option. Yes, some AJAX could give the user some visual
feedback that the server just didn't choke on their request and
something is actually happening, but I know that I, personally,
wouldn't want to sit and watch a page, waiting for some progress bar to
fill if I didn't have to.

If this is the final step in the process (ie: after the files are
uploaded, no more user input is required), then consider letting
another php script handle the long operation. You have a couple of
options here, then. You could just have a script scan the system for
new files to process and run it periodically via cron, or you could use
the system [1] function and call another script to run immediately
after the files are successfully uploaded. (There is a comment about
halfway down the page giving an example of how to sent the command as a
background process, so it doesn't make your script wait). Both of
these methods have the benefit that the heavy processing time takes
place outside of the browser request, meaning that you can do your
processing while allowing the user to continue browsing the site.

If you need some kind of visual feedback to the user, you could have
the processing script update a field in a table giving the current
status, and then query that for the user. Or, after the files are
uploaded, just give the user a message saying something like, "Your
files should appear in your photo album shortly."

[1] - http://us3.php.net/manual/en/function.system.php

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация