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 data
>
> 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
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
>
> > 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 ($
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) {
>
> >> > 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
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
>
> 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
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
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 of it (and waiting for
10 matches
Mail list logo