Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Forking and DBI

by tadman (Prior)
on Dec 12, 2002 at 22:14 UTC ( [id://219444]=note: print w/replies, xml ) Need Help??


in reply to forking and dbi

What you might consider doing is making sure that you aren't forking with any database handles open. Shut them all down, fork, and bring them back as required. For example:
my $dbh = DBI->connect(...); $dbh->do(...); $dbh->disconnect(); foreach (...) { ... fork ... } $dbh = DBI->connect(...); $dbh->do(...); $dbh->disconnect();
This would look a lot better if you organized things into functions.

I think what is occuring is that the forked scripts are trying to close out the DBI connection that they inherit from the parent process. Since you can't close them more than once, you're in trouble just having them around at all when forking.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found