help on LWP::Parallel

Discussion in 'Perl' started by jliang888@yahoo.com, Mar 8, 2005.

  1. Guest

    Is there anyway can make my script continue to run? If I just run 1st
    and 2nd or 1st and 3rd in the request list, the script won't be
    terminated, but it will be broken when list contains both 2nd and 3rd
    URLs.

    #!/usr/bin/perl -w
    require LWP::parallel::UserAgent;
    use HTTP::Request;

    # display tons of debugging messages. See 'perldoc LWP::Debug'
    #use LWP::Debug qw(+);

    # shortcut for demo URLs

    my $reqs = [
    HTTP::Request->new('GET', 'http://www.yahoo.com'),
    HTTP::Request->new('GET', 'http://www.oceanestatesa.com'),
    HTTP::Request->new('GET',
    'http://www.oceanstatenautical.com'),
    ];

    my $pua = LWP::parallel::UserAgent->new();
    $pua->in_order (1); # handle requests in order of
    registration
    $pua->duplicates(0); # ignore duplicates
    $pua->timeout (2); # in seconds
    $pua->redirect (1); # follow redirects

    foreach my $req (@$reqs) {
    print "Registering '".$req->url."'\n";
    if ( my $res = $pua->register ($req) ) {
    print STDERR $res->error_as_HTML;
    }
    }
    my $entries = $pua->wait();

    foreach (keys %$entries) {
    my $res = $entries->{$_}->response;

    print "Answer for '",$res->request->url, "' was \t",
    $res->code,": ",
    $res->message,"\n";
    }



    Thnaks.


    J.
     
    , Mar 8, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zeke Koos
    Replies:
    0
    Views:
    218
    Zeke Koos
    Sep 15, 2003
  2. Zeke Koos
    Replies:
    0
    Views:
    100
    Zeke Koos
    Sep 16, 2003
  3. Alex
    Replies:
    0
    Views:
    226
  4. Leif Wessman
    Replies:
    0
    Views:
    97
    Leif Wessman
    Jun 16, 2004
  5. Leif Wessman
    Replies:
    0
    Views:
    155
    Leif Wessman
    Sep 9, 2004
Loading...

Share This Page