Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^7: multi threading DBI

by BrowserUk (Patriarch)
on Oct 31, 2013 at 06:59 UTC ( [id://1060517]=note: print w/replies, xml ) Need Help??


in reply to Re^6: multi threading DBI
in thread multi threading DBI

I'm not psychic. Post the (exact) code that is giving you the errors.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.

Replies are listed 'Best First'.
Re^8: multi threading DBI
by supernoob (Novice) on Oct 31, 2013 at 07:42 UTC
    Yes, Sir! To isolate the error I disabled the DBI and even the LWP... so this script do nothing but printing ...
    #! perl use strict; use threads; use Thread::Queue; use LWP::Simple; use DBI; sub fetchNParse { my( $Qin, $Qout ) = shift; while( my $uname = $Qin->dequeue ) { #my $content = get $uname; #my @bits = $content =~ m[....]; my @bits=qw(pizza2 steak2 chicken2 burgers2); print " $uname 1\n"; #$Qout->enqueue( join $;, $uname, @bits ); $Qout->enqueue( $uname ); } $Qout->enqueue( undef ); } our $THREADS //= 16; my $Qunames = new Thread::Queue; my $Qrets = new Thread::Queue; threads->create( \&fetchNParse, $Qunames,$Qrets )->detach for 1 .. $TH +READS; #my $dbh = DBI->connect( ... ); #my $unames = $dbh->selectcol_arrayref("select uname from event"); my @unames = qw(pizza steak chicken burgers); print "a\n"; $Qunames->enqueue( @unames ); print "b\n"; for( 1 .. $THREADS ) { while( my $ret = $Qrets->dequeue ) { #my( $uname, @bits ) = split $;, $ret. #$dbh->do( insert stuff ); print "2\n"; } } #$dbh->disconnect;

      You can't get 2 variables from one shift.

      my( $Qin, $Qout ) = shift;

      And yes, I know I posted code that didn't work. I also warned you.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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.
        Got it, thanks! You're the man! Now I just have the problem with this script not stopping... all the threads seem to have completed operation but the perl script just wont stop by itself... any clue?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-03-19 06:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found