Re: [PHP] Fork and zombies

2009-03-17 Thread Per Jessen
Waynn Lue wrote: Here's pseudo code for what I'm trying to do: foreach ($things as $thing) { info = getInfo($thing); // uses a db connection makeApiCall(info); } makeApiCall(info) { $pid = pcntl_fork(); if ($pid == -1) { die(could not fork); } else if ($pid) { //

Re: [PHP] Fork and zombies

2009-03-17 Thread Waynn Lue
Here's pseudo code for what I'm trying to do: foreach ($things as $thing) { info = getInfo($thing); // uses a db connection makeApiCall(info); } makeApiCall(info) { $pid = pcntl_fork(); if ($pid == -1) { die(could not fork); } else if ($pid) { // parent,

Re: [PHP] Fork and zombies

2009-03-17 Thread Per Jessen
Waynn Lue wrote: I actually tried this in the meantime: $pid = pcntl_fork(); if ($pid == -1) { die(could not fork); } else if ($pid) { // parent, return the child pid echo child pid $pid waiting\n; pcntl_waitpid($pid, $status); if (pcntl_wifexited($status)) {

Re: [PHP] Fork and zombies

2009-03-17 Thread Per Jessen
Waynn Lue wrote: Ah, I was changing it to waiting for each child to finish in order to see if I could narrow down my db problem, because I figure this should be more or less equivalent to running it synchronously. Even like this, though, it still causes the db problem. I think the database

Re: [PHP] Fork and zombies

2009-03-17 Thread Waynn Lue
I think your waitpid() is in the wrong place, and at least you need use WNOHANG - unless you specifically want to wait for each child to finish before starting another one. But it still has the same problem, and I'm also trying to avoid pcntl_wait or pcntl_waitpid at all because I still

Re: [PHP] Fork and zombies

2009-03-16 Thread Per Jessen
Waynn Lue wrote: I periodically run a script that makes a call against a remote API, which takes some time to return. In an attempt to increase thoroughput, I decided to investigate using pnctl_fork to spawn off multiple processes to make the call, since the slowest part is the network part

Re: [PHP] Fork and zombies

2009-03-16 Thread Waynn Lue
Waynn Lue wrote: I periodically run a script that makes a call against a remote API, which takes some time to return. In an attempt to increase thoroughput, I decided to investigate using pnctl_fork to spawn off multiple processes to make the call, since the slowest part is the

Re: [PHP] Fork and zombies

2009-03-16 Thread Per Jessen
Waynn Lue wrote: While this works, it unfortunately leaves behind a zombie process every single time. You need to call pcntl_wait() or pcntl_waitpid(). Right, but if I do that, then the parent has to wait until the child completes before it exits. No it doesn't - just call

Re: [PHP] Fork and zombies

2009-03-16 Thread Waynn Lue
While this works, it unfortunately leaves behind a zombie process every single time. You need to call pcntl_wait() or pcntl_waitpid(). Right, but if I do that, then the parent has to wait until the child completes before it exits. No it doesn't - just call pcntl_wait() with

Re: [PHP] fork/spawnzombie question

2009-02-13 Thread Per Jessen
bruce wrote: Hi Nathan/Torok... Hey guys... got a bit of a question. I'm playing around with the php/for/pcntl_exec functions and I've got a process that spawns off a bunch of child processes. Unfortunately, I'm getting to where I have 100's of zombie child processes that I can see from

Re: [PHP] Fork PHP script X at a time.

2004-09-21 Thread John Wards
Not sure if anyone is interested in what I have come up with, its busy running just now but it seems to be performing ok. $do =0; $ok =0; $count=0; while($do!=1){ if($ok==0){ $sql = SELECT * FROM locations WHERE parent = '0' AND doing=0 and done !=1 ORDER BY num DESC

Re: [PHP] Fork PHP script X at a time.

2004-09-21 Thread John Wards
On Tue, 2004-09-21 at 13:58, John Wards wrote: Not sure if anyone is interested in what I have come up with, its busy running just now but it seems to be performing ok. Again adding to this thread for future reference. Its just compleated all 90 threads in 1 hour 50 minutes and that was

Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread Wouter van Vliet
Hi, I have a bit of a cold today so I probably would have figured this out for myself eventually but hey ;-) Right I have a script that I need to run around 90 times thru a cron job but passing a different i.d. to it each time. I have experimented with running all 90 at once and its a no

Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread John Wards
On Mon, 2004-09-20 at 16:45, Wouter van Vliet wrote: What I would like to do is fork off say 5-10 at a time and when one is done start another one in its place, as they all take different length of times to compleate. Any clues at where to start? Here is my fork all 90+ code...

Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread Marek Kilimajer
play around with popen() and stream_select() John Wards wrote: Hi, I have a bit of a cold today so I probably would have figured this out for myself eventually but hey ;-) Right I have a script that I need to run around 90 times thru a cron job but passing a different i.d. to it each time. I have

Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread John Wards
On Mon, 2004-09-20 at 16:56, Marek Kilimajer wrote: play around with popen() and stream_select() Oooh that looks handy. More night time reading I think! Any further ideas to save a man with a cold from using his brain would be great! Cheers John -- PHP General Mailing List

Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread raditha dissanayake
John Wards wrote: Hi, I have a bit of a cold today so I probably would have figured this out for myself eventually but hey ;-) Right I have a script that I need to run around 90 times thru a cron job but passing a different i.d. to it each time. not suprised. I have experimented with running

Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread Greg Donald
On Mon, 20 Sep 2004 16:36:51 +0100, John Wards [EMAIL PROTECTED] wrote: Right I have a script that I need to run around 90 times thru a cron job but passing a different i.d. to it each time. I have experimented with running all 90 at once and its a no go as it just makes the server run to

Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread Marek Kilimajer
John Wards wrote: On Mon, 2004-09-20 at 16:56, Marek Kilimajer wrote: play around with popen() and stream_select() Oooh that looks handy. More night time reading I think! Any further ideas to save a man with a cold from using his brain would be great! Cheers John Wanted to do something

Re: [PHP] Fork and multi-thread in PHP?

2002-06-12 Thread Rasmus Lerdorf
That's one of the main reasons you would want to use the mail() function. I wouldn't advise a fork() here, but if you really insist, see the pcntl extension - http://php.net/pcntl -Rasmus On Wed, 12 Jun 2002, Nathan Cassano wrote: Hi PHP folks, I have a program that sends out email by

Re: [PHP] fork?

2002-02-23 Thread Andrey Hristov
Vulcan Logic SRM www.vl-srm.net Every your task is a banana. Regards, Andrey Hristov - Original Message - From: Paul Roberts [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, February 23, 2002 1:05 PM Subject: [PHP] fork? how do i do two things at the same time, i'm thinking