Closed YuryPakhomov closed 6 months ago
From the NVALID PDL MAGICNO
in the error message, that seems to be coming from PDL code. And PDL seems to be its own (big) thing, so I don't think there is much we can do on our side. Sorry. :-(
@yanick As you can see on the PDL issue (https://github.com/PDLPorters/PDL-Opt-NonLinear/issues/6), this was a case of PDL working as designed, but not able to handle a process exit
ing because that DESTROY
s objects that were set up as lightweight and supposed to be then dealt with on return from the Perl function. My recommendation was to switch from using ->finish
from this module to POSIX::_exit
.
Is there however some scope for this module to have something like a finish_nodestroy
or similar to handle this sort of situation?
I think that you're in luck. Create a Child role like:
package Parallel::ForkManager::NoExitChild;
use strict;
use warnings;
use Carp;
use Moo::Role;
sub is_child { 1 }
sub is_parent { 0 }
sub start {
croak "Cannot start another process while you are in the child process";
}
sub finish {
my ($s, $x, $r)=@_;
$s->store($r);
}
1;
And use it as the child role in your ForkManager:
my $manager = Parallel::ForkManager->new( max_proc => 4, child_role => 'Parallel::ForkManager::NoExitChild' )
Although be careful! The children will not terminate as they hit finish
, so you'll have to make sure they don't do anything they shouldn't do in the main process loop.
Hello all!
I use PDL::Opt::NonLinear module in my code. Works fine. The code can be paralleled with Parallel::ForkManager for calculation of some function. Works fine. When I try to combine them, many warnings appear:
The simple code to reproduce this output is:
Child.pm line 26 contains CORE::exit($x || 0) of subroutine finish:
The messages "INVALID PDL MAGICNO" and "Warning: special data without datasv is not freed currently!" are generated by Basic/Core/pdlapi.c