in reply to Re^4: multi threading DBI
in thread multi threading DBI
Hm. That's not a "working, cut-down version" ...
So this isn't working either, but it ought to be close once you've filled in the blanks:
#! perl -slw use strict; use threads; use Threads::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[....]; $Qout->enqueue( join $;, $uname, @bits ); } $qOut->enqueue( undef ); } our $THREADS //= 16; my $Qunames = new Thread::Queue; my $Qrets = new Thread::Queue; threads->create( \&fetchNParse, $Qunames, $Qrets )->detach for 1 .. $T +HREADS; my $dbh = DBI->connect( ... ); my $unames = $dbh->selectcol_arrayref("select uname from event"); $Qunames->enqueue( @$unames ); for( 1 .. $THREADS ) { while( my $ret = $Qrets->dequeue ) { my( $uname, @bits ) = split $;, $ret. $dbh->do( insert stuff ); } } $dbh->disconnect;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: multi threading DBI
by Anonymous Monk on Oct 31, 2013 at 06:56 UTC | |
by BrowserUk (Patriarch) on Oct 31, 2013 at 06:59 UTC | |
by supernoob (Novice) on Oct 31, 2013 at 07:42 UTC | |
by BrowserUk (Patriarch) on Oct 31, 2013 at 08:22 UTC | |
by supernoob (Novice) on Oct 31, 2013 at 08:51 UTC | |
|