expresspotato has asked for the wisdom of the Perl Monks concerning the following question:
But it never does. Only when wait_all_children is included does the on_finish get run. We start a processor thread, because other threads are running as well (need not mention them here).$pm->run_on_finish( sub { my ($pid, $exit_code, $ident) = @_; print "** $ident just got out of the pool ". "with PID $pid and exit code: $exit_code\n"; } );
$thr4 = threads->new(\&processor); $thr4->detach; while (1){ sleep(1); #$pm->wait_all_children; }
Because $pm->wait_all_children is blocking, this prevents items to be processed from being added from an SQL Table, hence the while loop to look for new items. Without the blocking wait_all_children, things function as they should. However the system is left with TONS of zombie processes because finish never gets called. My only guess is it is because of the while (1){sleep 1;} But that is required to leave the detached threads still running. The system("kill $$"); is an attempt by me to get the zombie process ending. No dice. Even kill -9 (a supposed work around) does nothing. Any and all help is really appreciated.sub processor{ my @row; while (1){ if ($sys_ok){ @row = &row_sql("select * from pool_process where srv='$se +rver_id';"); if (!(@row)){ #print "Nothing to do...\n"; }else{ &del_sql("delete from pool_process where id='@row[0]'; +"); print "Processing (@row[1],@row[2],@row[3],@row[4])\n" +; #my $thr = threads->create(\&process_start,@row[1],@ro +w[2],@row[3],@row[4],@row[5]); $child_processor++; my $pid = $pm->start($child_processor) and next; &process_start(@row[1],@row[2],@row[3],@row[4],@row[5]); print "Child about to get out ($$)\n"; system("kill $$"); $pm->finish($child_processor); # Terminates the chil +d process print "Finished Child!"; } sleep(2); }else{ sleep(30); } #$pm->wait_all_children; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parallel Fork Manager -- Can't kill zombies!
by BioLion (Curate) on Oct 16, 2009 at 09:35 UTC | |
|
Re: Parallel Fork Manager -- Can't kill zombies!
by jakobi (Pilgrim) on Oct 16, 2009 at 11:02 UTC | |
|
Re: Parallel Fork Manager -- Can't kill zombies!
by fbicknel (Beadle) on Feb 09, 2010 at 16:32 UTC |