Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Sequential processing with fork.

by ikegami (Patriarch)
on Aug 04, 2015 at 20:03 UTC ( [id://1137422]=note: print w/replies, xml ) Need Help??


in reply to Re: Sequential processing with fork.
in thread Sequential processing with fork.

That's the most useless run_on_finish possible. Worse than none at all.
#!/usr/bin/perl use warnings; use strict; use Parallel::ForkManager qw( ); use constant MAX_WORKERS => 10; sub work { my ($client) = @_; print("$client start...\n"); sleep(3 + int(rand(2))); print("$client done.\n"); } { my $pm = new Parallel::ForkManager(MAX_WORKERS); # Optional. $pm->run_on_finish(sub { my ($pid, $exit, $ident, $signal, $core) = @_; if ($signal) { print("Client $ident killed by signal $signal.\n"); } elsif ($exit) { print("Client $ident exited with error $error.\n"); } else { print("Client $ident completed successfully.\n"); } }); for my $client (1..33){ $pm->start($client) and next; work($client); $pm->finish(); } $pm->wait_all_children(); }

Replies are listed 'Best First'.
Re^3: Sequential processing with fork.
by stevieb (Canon) on Aug 04, 2015 at 20:11 UTC

    Yes, I realized I had emptied it out previously after the fact. I'll leave it as is so this post retains context. Thanks for pointing it out.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1137422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found