in reply to Sharing DBI between threads
*** You are using a perl configured with threading enabled. *** You should be aware that using multiple threads is *** not recommended for production environments.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sharing DBI between threads
by BrowserUk (Patriarch) on Jan 21, 2010 at 14:39 UTC | |
Every program is a threaded program, even if it only has one thread. If DBI works correctly in all of those, then if some of them create a second thread:
it'll continue to work correctly. Provided you don't use DBI within that other thread! Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
|
Re^2: Sharing DBI between threads
by bagent (Novice) on Jan 21, 2010 at 23:01 UTC | |
| [reply] |
by afoken (Chancellor) on Jan 23, 2010 at 19:14 UTC | |
The problem is not Perl, and the problem is not thread support in Perl. Ikegami explained the real problem in Re: Sharing DBI between threads: A single database connection can not know which of the various threads sends commands, thus the database gets confused or damaged. You need a dedicated database connection for each single thread, period. (And you need it in every language that allows you to use threads and a database connection.) DBI WARNS not to use a threaded perl in a production environment. This does not mean DBI does not work with a threaded perl. It means that there MAY BE some issues with a threaded perl. You should perhaps read that warning as a better-safe-than-sorry warning: "it will very probably work as well, but we can not guarantee that as well as for a non-threaded perl". Every recent perl for Windows (with faked fork() support) is threaded, as are most perls built by the various Linux distributions. And all of those perls run pretty well with the DBI. Perl has really unsafe features - for example it allows interchange of HASH references and integers without any warning even with `use strict;` This sounds pretty strange, like a misunderstanding of some essential concepts of Perl. If not, could you show us a working example, and a copy of perl -V that exhibits that problem? Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Jan 23, 2010 at 20:07 UTC | |
it allows interchange of HASH references and integers I'm guessing that he means:
But as you say misunderstands that you can't (easily) go the other way. Also, perhaps he forgets that C allows you to cast a pointer to an integer; but more significantly cast an integer to a pointer (to anything). Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
by bagent (Novice) on Jan 23, 2010 at 21:30 UTC | |
> This sounds pretty strange, Not sure why `perl -V` is needed but here it is:
| [reply] [d/l] [select] |