HI, Following is the code for run_on_finish. I am writing data onto disk(/tmp/ directory) retrieved by each child process. and deleting those file after reading them.
$pm->run_on_finish(sub {
my ($pid, $exit_code, $ident) = @_;
eval {
my $filename = '/tmp/' . $$ . escape($ident);
my $result_set;
if (-e $filename) {
$result_set = $obj->retrieve($filename);
unlink($filename);
}else {
# need a new $timeout_result object every loop
my $timeout_result = new DBWIZ::Search::ResultSet;
$timeout_result->status('timeout');
$timeout_result->hits(-5);
$result_set = $timeout_result;
}
$return{$ident} = $result_set;
};
if ($@) { print STDERR "Problem with search module: $@\n"; }
# print STDERR "database $ident done = exit $exit_code \n";
});
$obj is the Data::Serializer object with following options
my $obj = Data::Serializer->new(
serializer => 'Storable',
portable => '1',
encoding => 'b64',
);
|