in reply to Sharing DBI handle per each thread

Is that impossible?

Straight outta the DBI docs:

Because of this (possibly temporary) restriction, newly created + threads must make their own connctions to the database. Handles can't b +e shared across threads.

You should probably perldoc DBI and search for the section on threads and thread safety. Note that the documentation's last word on the subject is, "Using DBI with perl threads is not yet recommended for production environments."

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Sharing DBI handle per each thread
by jdtoronto (Prior) on Aug 19, 2003 at 02:22 UTC
    From the DBI docs:

    However, the internal pointer data within the handles will refer to the DBI and drivers in the original interpreter. Using those handles in the new interpreter thread is not safe, so the DBI detects this and croaks on any method call using handles that don't belong to the current thread (except for DESTROY).

    Because of this (possibly temporary) restriction, newly created threads must make their own connctions to the database. Handles can't be shared across threads.

    But BEWARE, some underlying database APIs (the code the DBD driver uses to talk to the database, often supplied by the database vendor) are not thread safe. If it's not thread safe, then allowing more than one thread to enter the code at the same time may cause subtle/serious problems. In some cases allowing more than one thread to enter the code, even if not at the same time, can cause problems. You have been warned.

    Can't really be much plainer can it!

    jdtoronto