I'm trying to use Parallel::ForkManager to fork off multiple process to perform database queries/updates.
The code snippet:
As you can guess the process_templates subroutine is the one that handles the db functionality needed.
Using the above code, I get the following error:
Now, I did find some mention of the "clone" method:
However, I'm a little unsure of the usage.
I did try:
But, this results in a different error:
Any thoughts/expierences will greatly be appreciated!
X
The code snippet:
Code:
my $pm = new Parallel::ForkManager($result->rows);
while ( my ( $id, $scheduled, $lastgenerationdate ) =
$result->fetchrow_array() )
{
my $pid = $pm->start and next;
&process_templates($id, $scheduled, $lastgenerationdate, $dbh, $datetime, $pid, $cgi, $config);
$pm->finish;
}
As you can guess the process_templates subroutine is the one that handles the db functionality needed.
Using the above code, I get the following error:
Code:
DBD::mysql::db prepare failed: handle 2 is owned by thread 223eec not current th
read 210b014 (handles can't be shared between threads and your driver may need a
CLONE method added) at ../cgi-bin/lib/RTH_Template.pm line 251.
Now, I did find some mention of the "clone" method:
However, I'm a little unsure of the usage.
I did try:
Code:
my $pm = new Parallel::ForkManager($result->rows);
while ( my ( $id, $scheduled, $lastgenerationdate ) =
$result->fetchrow_array() )
{
my $pid = $pm->start and next;
my $newdbh = $dbh->clone();
&process_templates($id, $scheduled, $lastgenerationdate, $newdbh, $datetime, $pid, $cgi, $config);
$newdbh->disconnect();
$pm->finish;
}
But, this results in a different error:
Code:
DBD::mysql::db clone failed: handle 2 is owned by thread 223eec not current thre
ad 210ba64 (handles can't be shared between threads and your driver may need a C
LONE method added) at C:\dev\executor.pl line 81.
Any thoughts/expierences will greatly be appreciated!
X