in reply to Re: running another script without waiting
in thread running another script without waiting

Thank you for the reply. I am using this command in the scheduler:

foreach $url ( @scheduled_jobs ) {
    $req = new HTTP::Request GET => $url;
    $res = $ua->request($req);
}

The scheduler is a daemon forked into the background. I am running everything on FreeBSD.

Your post is interesting - making grandchildren. I could give that a try.
  • Comment on Re: Re: running another script without waiting

Replies are listed 'Best First'.
Re: Re: Re: running another script without waiting
by Roger (Parson) on Oct 08, 2003 at 07:49 UTC
    I see that you are using LWP::UserAgent module. That's where your problem lies, because I believe the user agent is a single threaded process that waits for the GET to complete before processing the next request.

    So if you change your scheduler to the following, it should HTTP get all your scheduled jobs without waiting for them to complete:

    foreach $url ( @scheduled_jobs ) { my $ua = new LWP::UserAgent; my $req = new HTTP::Request GET => $url; my $pid = fork(); if ($pid == 0) { # in the child my $res = $ua->request($req); exit(0); } # in the parent, carry on with next job... }
    I haven't tested the code, but I believe if you do something along the line, it should work.