#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Proc::Queue size => 3, qw(run_back waitpids); my $starttime = time; my $user_agent = LWP::UserAgent->new; $user_agent->timeout(30); my @urlstoget = qw( http://foo.com http://bar.com http://etc.com http: +//and-so-on.com ); my @pids; for my $url (@urlstoget) { push @pids, run_back { my $request = HTTP::Request->new('GET', $url); my $response = $user_agent->request($request); my $dbh = connectdb('listeningpost'); processresponse($response) }; } waitpids(@pids); my $elapsed = time - $starttime; open LOG, ">", "getitemshtmlog.txt" or die "unable to open log file"; print LOG "$n urls in $elapsed seconds, ",$elapsed/$n," sec per url\n" +;
If this version doesn't work yet, it could be a bug on Proc::Queue, in that case send the author (=> me) a bug report with your full script or post it here.
In reply to Re: fork/threads: running after childrem
by salva
in thread fork/threads: running after childrem
by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |