problem with ithreads

From: Oleg Feotast (feotast_at_feotast.net)
Date: 12/29/04

  • Next message: Qukasz_M=B1drzycki?=: "[RFC] Money::PaymentPreparer - change sum to bills and coins"
    Date: Wed, 29 Dec 2004 20:26:16 +0200
    
    

    Hi.

    I have FreeBSD 4.9 and Perl 5.8.6 with useithreads=define installed.

    I run my script (source in the and of the message) and it works OK for 15-30
    minutes. After that it slows down and soon freezes. I put counter in while
    loop of thread_do sub to count how many requests each thread do. Each thread
    do 100-150 requests and after that die. When I send INT signal after script
    worked for 40 minuets I get message: "A thread exited while 4 threads were
    running". I tried to put the body of loop into eval block but it didn't
    worked.

    Why thread die after and how to fix solve problem? Please, help me.

    #!/usr/bin/perl
    use strict;
    use threads;
    use threads::shared;
    use Thread::Queue;
    use LWP::UserAgent;
    use HTTP::Request::Common;

    $| = 1;

    my $thread_num : shared = 0;
    my $max_thread = 50;
    my $exit = 0;
    my $result_q = Thread::Queue->new();

    threads->new(\&thread_do) for (1..$max_thread);

    while (!$exit) {
        for (my $i = 0; $i < $result_q->pending(); $i++) {
            print $result_q->dequeue() . "\n";
        }
    }

    print "Done\n";

    sub thread_do
    {
        threads->self->detach();
        my $tid = threads->self->tid();
        while (1) {
            my $ua = LWP::UserAgent->new(timeout => 3);
            my $res = $ua->request(HEAD 'http://microsoft.com/');
            $result_q->enqueue("$tid;" . $res->code() . ";" . $res->message() .
    ";");
        }
    }


  • Next message: Qukasz_M=B1drzycki?=: "[RFC] Money::PaymentPreparer - change sum to bills and coins"

    Relevant Pages

    • Re: Loop for only 10 cycles
      ... I will not comment on other issues, but altered your script ... I'm concerned that it will get caught in a never ending loop ... > Drive, intDrive, intTry, intTryMax ... > Sub QDRIVE ...
      (microsoft.public.windows.server.scripting)
    • Re: Syntax Problem...
      ... >> I'm tring to write a script that verifies if the time of the last ... sub Check_Mod ... But it runs in an infinite loop that I would only like to run every 60 ... Do I have the sleep function in the correct place, ...
      (comp.lang.perl.misc)
    • Re: reload the vbscript itself within a vbscript
      ... Loop ... >> input is less than 1 character long, the script will reload. ... >> However, the problem is that it is sub procedure, the sInputUserDept is ...
      (microsoft.public.scripting.vbscript)
    • Re: Greasemonkey seems to fail with too many gm_xmhttprequests?
      ... works if I keep the loop to one, but if I try and loop through all the ... rows, and therefore have say 10-20 gm_xmlhttprequests, the script just ... I just want it all to load when the page loads. ... Too many outstanding requests. ...
      (comp.lang.javascript)
    • RE: OWA usage analysis script
      ... I'll just keep this script updated on PSC ... > sub processfile ... > Hits Long, TS DateTime)" ...
      (microsoft.public.exchange2000.clients)