Re: [CDBI] Class:DBI::Loader, Net::Daemon, threads and... ewww... :)

[prev] [thread] [next] [Date index for 2005/09/27]

From: Mike Whitaker
Subject: Re: [CDBI] Class:DBI::Loader, Net::Daemon, threads and... ewww... :)
Date: 07:39 on 27 Sep 2005
On 26 Sep 2005, at 23:52, Matt S Trout wrote:

>> OK. Fair enough. I'm probably being naughty. But is there a way of
>> preserving the Class::DBI::Loader constructed relationships and
>> hooking a new DBI handle on the back end?
>>
>
> Simple. Immediately after the loader's done it's job, call
>
> CDBIBase->db_Main->disconnect; # Where your tables are CDBIBase::Table
>
> That'll disconnect the stored dbh. Provided nothing touches the db  
> between
> then and when you spawn the threads that do the work, the first db  
> operation
> each thread initiates will connect its own dbh and you should be fine.

Nothing can, 'cause all the DB calls are caused to happen by talking  
to the daemon :)

> This certainly works ok in a fork/exec environment, but there may  
> be caveats
> under threading that I'm not aware of. Give it a go and tell us how  
> you get
> on :)

Here goes...

Hrm...
OK.

My tables all use additional_base_classes Foo::Base.
Both Foo::Base->db_Main->disconnect and Foo->db_main->disconnect give  
me 'Can't locate object method "db_Main" via package "Foo"' (or  
Foo::Base).

$loader->find_class('a_class')->db_Main->disconnect works, but I  
still get the:

DBD::mysql::db FETCH failed: handle 2 is owned by thread 814c008 not  
current thread 8ea9130 (handles can't be shared between threads and  
your driver may need a CLONE method added) at /usr/share/perl5/Ima/ 
DBI.pm line 316, <GEN12> line 2.

*scratches head*

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

Re: [CDBI] Class:DBI::Loader, Net::Daemon, threads and... ewww... :)
Mike Whitaker 07:39 on 27 Sep 2005

Generated at 17:55 on 28 Sep 2005 by mariachi v0.52