AV-2 has asked for the wisdom of the Perl Monks concerning the following question:
Basically it is a script that creates a database handler. Then, at some point, after testing several conditions it might fork. After forking, it will attempt to access the database, but I get an error. It warns me that the handle number x is owned by the thread y, not current z thread, and handles can't be shared. Then it suggests me that somehow performing a clone on the db handler will somehow, magically solve my problem. I have tried using clone on several ways, but I don't have too much experience with fork. In fact, this is the first time I am using it, to avoid enclosing half of my script in a loop that will only execute two times. I appreciate all the help you can give me.use DBI; use strict; use warnings; my $db = DBI->connect(qq/dbi:SQLite:dbname=test/); my $pid = fork(); $db->do("DROP TABLE IF EXISTS foo"); waitpid($pid,0); $db->disconnect;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI handler after perfoming fork?
by jasonk (Parson) on Apr 12, 2008 at 02:35 UTC | |
by AV-2 (Novice) on Apr 12, 2008 at 02:42 UTC | |
|
Re: DBI handler after perfoming fork?
by kyle (Abbot) on Apr 12, 2008 at 04:43 UTC |