Usually the best solution is to use whatever backend you are talking to correctly. For a long-running MySQL query, for example, you should have a look at the non-blocking mysql_unbuffered_query() call.
There is a fork() function in the pcntl extension and there is also a very experimental thread extension in PECL, but both of these should be a last resort. -Rasmus On Tue, 26 Nov 2002, ROBERT MCPEAK wrote: > Rasmus, > > Thanks for you reply. I agree that what you suggest is the correct solution for the >mail delivery scenario I used as an example. > > My example was poor in that in limited the scope of what I was asking. > > I have other situations where I would like to somehow "spawn" a new php process so >that the page loads quickly and my user doesn't get frustrated or confused. > > Another such situation would be when I do time consuming operations on a MySql >table, such as building an index or loading data. These operations may take several >minutes and I'd like to avoid having to make my user wait for the page to load. > > What is the correct solution for this problem? > > I'm a newcomer to PHP, am quite excited by it, and really appreciate your insight. > > Thanks, > > Bob > > >>> Rasmus Lerdorf <[EMAIL PROTECTED]> 11/26/02 11:46AM >>> > The correct solution for this particular problem is to just queue the > outbound mail and have your MTA deliver them out of band. "man sendmail" > > -Rasmus > > On Tue, 26 Nov 2002, ROBERT MCPEAK wrote: > > > I'm interested in spawing a new PHP process -- if that's the correct terminology. > > > > The situation is that I've got a very slow loading page, where, for example, I'm >using PHP to send, say, 1000 emails. The user clicks submit, and, although PHP is >firing out the emails, it appears to the user that page is hanging. I'd like to >somehow send that process to the background and let the page load straight-away. > > > > In another scripting language I've used, this function was called "spawn." > > > > Do we have something like this in PHP (I know we do!! Just can't find it.) I've >looked through the docs but don't see what I'm looking for. > > > > Thanks in advance. > > > > -Bob > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php