Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: parallelising processes

by tomfahle (Priest)
on Feb 06, 2011 at 17:17 UTC ( #886533=note: print w/replies, xml ) Need Help??


in reply to parallelising processes

Have a look at Parallel::Iterator, too.

You can set the number of parallel workers with the option workers:

use strict; use warnings; # Number of parallel tasks my %options = (); $options{workers} = 8; # Execute tasks in parallel my @results = iterate_as_array( \%options, $worker, \@tasks );

Hth, Thomas

Replies are listed 'Best First'.
Re^2: parallelising processes
by hermida (Scribe) on Feb 06, 2011 at 21:29 UTC
    Also have a look at Parallel::Forker, I use it all the time it works great exactly as you expect and has advantages over Parallel::ForkManager like child process signalling.
    use Parallel::Forker; my $forker = Parallel::Forker->new(use_sig_child => 1, max_proc => 8); $SIG{CHLD} = sub { Parallel::Forker::sig_child($forker); }; $SIG{TERM} = sub { $forker->kill_tree_all('TERM') if $forker && $forke +r->in_parent; }; for (1..10) { $forker->schedule(run_on_start => sub { # do child process code here })->ready(); } # wait for all child processes to finish $forker->wait_all();
    hth
Re^2: parallelising processes
by RobertCraven (Sexton) on Apr 07, 2011 at 08:02 UTC
    Thank for your answer, unfortunately Parallel::Iterator is also not available in that environment.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-10-18 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (72 votes). Check out past polls.

    Notices?