Subject: | SubProcess may not include all required modules (alt_fork only) |
Because of the way alt_fork runs perl all modules needed
may not get loaded. There may be other modules that tickle this bug,
but I ran into it with Math::BigInt.
Attached is a simple script to reproduce the problem.
SimpleDBI has essentially the same issue see RT ticket #48401 for one
possible solution.
Subject: | dbi-easy.pl |
use POE qw( Component::EasyDBI );
use Math::BigInt;
# Set up the DBI
POE::Component::EasyDBI->spawn( # or new(), which returns an obj
alias => 'EasyDBI',
dsn => 'DBI:mysql:database=test;host=localhost;port=3306',
username => 'user',
password => 'password',
alt_fork => 1,
);
# Create our own session to communicate with EasyDBI
POE::Session->create(
inline_states => {
_start => sub {
$_[KERNEL]->post( 'EasyDBI',
do => {
sql => 'CREATE TABLE IF NOT EXISTS `test`.`my_bigint` (`my_int` INTEGER NOT NULL) ENGINE = MyISAM',
event => 'table_created',
}
);
},
simple_res => sub {
if ($_[ARG0]->{error}) {
warn "EasyDBI : ",$_[ARG0]->{error},"\n";
warn "EasyDBI : ",$_[ARG0]->{sql},"\n";
} else {
warn "success\n";
}
},
table_created => sub {
my $val = int(rand(42));
my $bi_val = Math::BigInt->new("-$val");
$_[KERNEL]->post( 'EasyDBI',
insert => {
sql => 'INSERT INTO `test`.`my_bigint` (`my_int`) VALUES (?)',
placeholders => [$val],
event => 'simple_res',
},
);
$_[KERNEL]->post( 'EasyDBI',
insert => {
sql => 'INSERT INTO `test`.`my_bigint` (`my_int`) VALUES (?)',
placeholders => [$bi_val],
event => 'simple_res',
},
);
$_[KERNEL]->post( 'EasyDBI' => 'shutdown' );
},
},
);
$poe_kernel->run();