"Best"?

What may be best for me may not be best for you. Heck, I've done that in at least three different ways, none of which are likely to be considered "best" by at least a handful of others, probably many others.

I've done forking/execing/waiting by hand. I've used Parallel::ForkManager (in the child you can simply exec your proc_script and then $pm->wait_all_children after you're done forking them all off). Most recently, I've adopted AnyEvent to manage this. And I'm looking at AnyEvent::Fork and friends (e.g., AnyEvent::Fork::RPC) for the future.

Proc::JobQueue also looks interesting, though it might be a bit heavy for what you're doing.

These all have pros and cons, so it really depends on what you want to do. I suspect that Parallel::ForkManager might be the easiest solution that I'm familiar with for Doing The Right Thing for you. Because you don't really want to fork off a separate script for each file all at the same time. Parallel::ForkManager is one solution (of at least a few, I'm sure) that can make it easy to ensure you don't have too many going at a time by placing a limit on how many forks are running at a time.


In reply to Re: Best way to synchronise scripts by Tanktalus
in thread Best way to synchronise scripts by kosie99

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.