I got the following errors:use strict; package MyClass; use base 'Class::DBI'; __PACKAGE__->set_db('Main','dbi:mysql:test', 'test','test'); __PACKAGE__->table('MYCLASS'); __PACKAGE__->columns(Primary=>qw/ID/); __PACKAGE__->columns(Others => qw/NAME/); package main; use threads; my $s = MyClass->retrieve(1); threads->new(\&test, $s)->join(); print "done\n"; exit 0; sub test{ my $o = shift; print $o->name,"\n"; }
The first error is instructive, but I'm not sure how to fix it, can one pass the objects retrieved via Class::DBI to other threads? by the way, line 316 of DBI.pm is the "unless" line in the following:thread failed to start: DBD::mysql::db FETCH failed: handle 2 is owned + by thread 22432c not current thread 1b1e014(handles can't be shared +between threads and your driver may need a CLONE method added) at C:/ +Perl/site/lib/Ima/DBI.pm line 316. Attempt to free non-existent shared string 'test~~test~~test~~AutoComm +it~~ChopBlanks~~FetchHashKeyName~~PrintError~~RaiseError~~RootClass~~ +ShowErrorStatement~~Taint~~Username~~dbi_connect_method~~1~~1~~NAME_l +c~~0~~1~~DBIx::ContextualFetch~~1~~1~~test~~connect_cached' during gl +obal destruction. Free to wrong pool 1b24430 not 222770 during global destruction.
I'm more at a loss to the second one, it seems to be some db connection string, but who's doing the destruction and garbage collection here? Thanks.sub _mk_db_closure { my ($class, @connection) = @_; my $dbh; return sub { unless ($dbh && $dbh->FETCH('Active') && $dbh->ping) { $dbh = DBI->connect_cached(@connection); } return $dbh; }; }
In reply to threading problem with Class::DBI by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |