Indeed I tried that one, and you're right I should have been a
bit more specific.
It does exactly what I want it to do, at least the example
code.
The moment I start messing around by, say, adding a home-brew
module (which contains really nothing special but some
common stuff to be re-used by other scrips), it 'misbehaves'.
This misbehaviour means that when I specify a processqueue
of 10, it runs 10 processes, but does not respawn new ones.
At the end just 10 processes have run and
finished.
The examplecode I use is mostly from the book, slightly customized:
#perl.exe -w # INIT ---- use strict; use Parallel::ForkManager; use MyTest; # Mind this one, it's the one that messes things up # VARS ---- my $max_procs = 10; my $wait = 5; my @collections = qw( adw adw_wet_compleet ag-dou ag-gi ag-hc ag-hlo a +g-its-sol ag-its-sol-hot agents alg_diversen alg_dossier_juris_en_res +o alg_ellis alg_ellis_en alg_kb alg_kfb alg_kluwer_rest alg_pdf alg_r +est alg_sdu am b_adw b_adw_wet_compleet b_ag-dou b_ag-gi b_ag-hc b_ag +-hlo b_ag-its-sol b_ag-its-sol-hot b_agents b_alg_diversen b_alg_doss +ier_juris_en_reso b_alg_ellis b_alg_ellis_en b_alg_kb b_alg_kfb b_alg +_kluwer_rest b_alg_pdf b_alg_rest b_alg_sdu b_am b_bibliotheek b_bm b +_bna-mix b_browsedocs b_curbel b_fmod b_help b_hvg b_hvg-kluwer b_mrp + b_pz b_refdocs b_tss b_tss-pdf bibliotheek bm bna-mix browsedocs cu +rbel fmod help hvg hvg-kluwer images mrp pz refdocs tss tss-pdf ); # MAIN ---- my $pm = new Parallel::ForkManager($max_procs); # Setup a callback for when a child finishes up so we can # get it's exit code $pm->run_on_finish( sub { my ($pid, $exit_code, $ident) = @_; print "** $ident finished (PID: $pid) and exit code: $exit_cod +e\n"; } ); $pm->run_on_start( sub { my ($pid,$ident)=@_; print "** $ident started, pid: $pid\n"; } ); $pm->run_on_wait( sub { print "** waiting\n"; }, 0.5 ); foreach my $child ( 0 .. $#collections ) { my $pid = $pm->start($collections[$child]) and next; # This code is the child process print "Child: $collections[$child]\n"; sleep $wait; # End of child process $pm->finish($child); # pass an exit code to finish } print "Waiting for Children...\n"; $pm->wait_all_children; print "Everybody is out of the pool!\n";
I pin-pointed the problem, try this for the 'MyTest' module...
package MyTest; #--------------------------------------------------------------------- +--- # INIT #--------------------------------------------------------------------- +--- use strict; use Win32::OLE; use Win32::OLE::Variant; 1;

This will show the problem as mentioned above.
Needs some meditation, does it? :-)


In reply to Re^2: Parallel tasks by john.goor
in thread Parallel tasks by john.goor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.