in reply to Re: HTTP Requests and Threading
in thread HTTP Requests and Threading

Hi ken, Thanks for the thorough message. I am having difficulties with outputting my data to stdout, in the format that I wanted. The way I wrote it is when the individual threads complete, they execute this code:

if( $response->is_success ) { print"\n\n", $counter_thread++,"th :", "Dumped Data Return +ed:\n\n ", Dumper($response->decoded_content), "\n" ; print "Response code: ", $response->code, "\n", "HTTP Response Message: ", $response->message, " ", "\n"; } else { print STDERR $response->status_line, "\n"; }

However, they come out in unsorted order. I am trying to print each thread in order with time elapsed for each thread, decoded_content in a neat way. As an example, the variable '$counter_thread' would print like 2,5,8, 10,7, etc. to stdout. Is this a threading issue? What is the best way to go about this? Chris

Replies are listed 'Best First'.
Re^3: HTTP Requests and Threading
by BrowserUk (Patriarch) on Mar 06, 2014 at 20:44 UTC

    Your threads run concurrently and will take different times to complete depending upon a bunch of factors -- the remote server's workload; distance and latency of the link between your machine and those servers; the size of the page returned; etc. -- so the order in which they finish will be unrelated to the order that you start them. That is normal.

    If you want to control the order of the output, you will need to accumulate the results and arrange to output them in your desired order.


    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.

      That makes sense.

Re^3: HTTP Requests and Threading
by PerlSufi (Friar) on Mar 06, 2014 at 19:49 UTC