in reply to Crash with ForkManager on Windows
G'day amitsq,
I suspect your problems are related to the additional $pm->finish and next statements.
Your instantiation of the Parallel::ForkManager object may also be an issue. What you have is different from every example shown in the documentation; also see "perlobj: Invoking Class Methods" (including its "Indirect Object Syntax" subsection).
Using exactly the same message to identify your different cases is pointless: use meaningful messages.
I rewrote your code like this (pm_1199760_parallel_forkmgr_link_checker.pl):
#!/usr/bin/env perl -l use strict; use warnings; use LWP::Simple; use Parallel::ForkManager; my @urls = qw{ http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif http://hooboy.no-such-host.int/ http://www.yahoo.com http://www.ora.com/ask_tim/graphics/asktim_header_main.gif http://www.guardian.co.uk/ http://www.pixunlimited.co.uk/siteheaders/Guardian.gif }; my $max_processes = $ARGV[0] || 8; my $pm = Parallel::ForkManager::->new($max_processes); print 'Start link checking.'; for my $url (@urls) { $pm->start and next; my ($type, undef, $mod) = head($url); if (defined $type) { print "PASS: $url"; print ' MOD: ', $mod || 0; } else { print "FAIL: $url"; } $pm->finish; } $pm->wait_all_children; print 'Link checking completed.';
Here's the output with no argument:
$ pm_1199760_parallel_forkmgr_link_checker.pl Start link checking. FAIL: http://hooboy.no-such-host.int/ PASS: http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif MOD: 1354074654 PASS: http://www.guardian.co.uk/ MOD: 0 FAIL: http://www.ora.com/ask_tim/graphics/asktim_header_main.gif PASS: http://www.yahoo.com MOD: 0 FAIL: http://www.pixunlimited.co.uk/siteheaders/Guardian.gif Link checking completed.
I then ran it with arguments of 8, 5, 3, 2 and 1. Lke the first run (with no argument), all ran to completion: no crashes! With the exception of 1, they produced the same results (although the order of output varied).
Running with an argument of 1 rather defeats the purpose of running processes in parallel; however, as you said you'd used it, I tried it also. Here's what I got:
$ pm_1199760_parallel_forkmgr_link_checker.pl 1 Start link checking. PASS: http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif MOD: 1354074654 FAIL: http://hooboy.no-such-host.int/ PASS: http://www.yahoo.com MOD: 0 FAIL: http://www.ora.com/ask_tim/graphics/asktim_header_main.gif FAIL: http://www.guardian.co.uk/ FAIL: http://www.pixunlimited.co.uk/siteheaders/Guardian.gif Link checking completed.
I ran that a second time: the result was the same. I'll leave you to investigate that further.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Crash with Parallel::ForkManager on Windows
by Discipulus (Canon) on Sep 21, 2017 at 09:27 UTC | |
by kcott (Archbishop) on Sep 21, 2017 at 10:03 UTC | |
by holli (Abbot) on Sep 21, 2017 at 12:46 UTC | |
by kcott (Archbishop) on Sep 22, 2017 at 06:15 UTC | |
|
Re^2: Crash with ForkManager on Windows
by amitsq (Beadle) on Sep 21, 2017 at 10:18 UTC | |
by kcott (Archbishop) on Sep 22, 2017 at 06:07 UTC | |
by Discipulus (Canon) on Sep 22, 2017 at 07:25 UTC |