[Trilug-ontopic] perl and threads
gwbrown1 at gmail.com
Sun Mar 13 17:33:23 EDT 2011
I found a good example using both threads and forks to accomplish a basic
script that I thought I'd pass along.
On Fri, Mar 11, 2011 at 12:11 PM, Michael Peters <mpeters at plusthree.com>wrote:
> On 03/11/2011 10:00 AM, Brian Weaver wrote:
> I don't know about using threads, but if you want multiple instances with
>> each working on a single device then why not use a master-child process
>> model? Have the master fork off N children and maintain a link using
>> anonymous pipes, unix sockets, or some other IPC mechanism. The master can
>> inform each child on what system to query and then receive a status back
>> from the child when it's done.
> I agree that you should use processes instead of threads. Threads are ok in
> Perl but processes are better and since processes are COW in Linux you end
> up having about the same amount of overhead.
> But instead of writing your own from scratch, I'd look to CPAN (Perl's
> biggest weapon) to find something to handle all of the gory bits for you. I
> like Parallel::ForkManager
> Michael Peters
> Plus Three, LP
> Trilug-ontopic mailing list
> Trilug-ontopic at trilug.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Trilug-ontopic