Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Best way to synchronise scripts

by Tanktalus (Canon)
on Jan 09, 2014 at 05:07 UTC ( [id://1069909]=note: print w/replies, xml ) Need Help??


in reply to Best way to synchronise scripts

"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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-23 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found