Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Using DBI::clone()

by rob_au (Abbot)
on Sep 30, 2003 at 04:49 UTC ( [id://295178]=note: print w/replies, xml ) Need Help??


in reply to Using DBI::clone()

You might want to have a read of the DBI man page, specifically the section relating to Threads and Thread Safety as the behaviour which you are describing is similar to that performed when additional threads are created after the creation of a DBI object. Cloned DBI objects retain the internal data pointers of the original object - This in turn causes a threaded Perl to croak when accessing DBI handles which do not belong to the current thread (excepting DESTORY).

Similarly, the outcome of all this is that if you want each forked process to have a separate database handle, these handles should be created after forking the original process.

 

perl -le "print+unpack'N',pack'B32','00000000000000000000001010001000'"

Replies are listed 'Best First'.
Re: Re: Using DBI::clone()
by gnu@perl (Pilgrim) on Sep 30, 2003 at 12:58 UTC
    Thats actually what I thought but I still didn't understand why each handle in the child (after forking) was the same. One would think (expect?) that they would be different.

    I guess I'll just have to connect to the DB manually in the child post-fork.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://295178]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-25 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found