Reply to Re: [PHP] How to handle actions that may take a long time?

Your name:

Reply:


Posted by Cajus Pollmeier on 03/01/05 10:56

Am Dienstag, 1. März 2005 01:24 schrieb Richard Lynch:
> Cajus Pollmeier wrote:
> > I'd like to know your opinion about how to handle events that may take
> > more than a minute to finish in PHP. In this case, the code is
> > performing a recursive action on a large LDAP tree where I'd like to
> > present something like a status page ("Please wait, blah blah" with
> > some animated gif or so), while the action takes place in background.
> >
> > Is it possible to fork away this PHP code and set some SESSION vars to
> > trigger the end of the status page? Or do I have to put this action
> > behind a one pixel image and act when the page is "really" complete?
> > Also I'm not sure how to handle the script execution timeout problem...
>
> Do you really expect the user wants to sit there for all the time waiting
> for the process to finish?

Yes. Should be the case, because later actions would depend on a changed data
set. In this case I'm renaming entries of a complete subtree. This may last a
long time and should not be abortable in any way. While this may change the
data the user is working on, he/she should wait till it is completed.

> Is there ANY way to factor out that code and do it before they get there?
> Obviously not for a search where the user types in what they want, but is
> that what you are doing? You don't say; I can't guess.

See above.

> Basically, if I have to sit there waiting, then I'm not really all that
> impressed with an animated gif or whatever...

Not you. But most people are not impressed by a spinning gear, globe or
whatever your browser shows up.

> Perhaps you have them logged in already, and you could record their search
> parameters and assign it an ID, and perform the search in the background,
> and then have a page to deliver the results to later.

I'm not sure how I could fork away a PHP process to be not interruptible, or
behave like you're writing above.

Just thinking about a session thingie. Place a little iframe on the page which
reloads once a second and check a session variable if we're finished. If we
are, reload the parent page.

Thanks,
Cajus

[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

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