Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

A job scheduler for the threads module

by samwyse (Scribe)
on Dec 24, 2012 at 20:31 UTC ( #1010230=perlquestion: print w/ replies, xml ) Need Help??
samwyse has asked for the wisdom of the Perl Monks concerning the following question:

I need to access a variety of networking equipment and start a debug log on each, then wait for an event on another server, then re-access the networking equipment to stop the debug mode, and finally collect the logs for upload to an FTP site. I am using the threads module but the details of the requirements have reached the point where I feel that some sort of scheduler is required.

I have a precedence list, such as used in a topo sort, to determine which tasks need to wait for which other tasks to complete before they can run. In all but one case, each task needs to wait for all of it's preceding tasks to complete before it can execute, however tasks can and should be executed in parallel when ever possible. Every example that I have found for using the threads module starts all possible tasks at the same time and waits for them all to complete before proceeding. This is not what I need to do, I have a "skein" of tasks to be executed. (The one exception to the wait-for-all rule is that I have two tasks that need to wait for either of them to finish instead of both. One of the tasks is grepping a remote log file looking for a match, the other task is waiting for the remote machine to crash. If either task finishes, the other should be aborted and I can continue with the next step.)

Can anyone point me to a package or code that accomplishes what I need to do? Many thanks.

Comment on A job scheduler for the threads module
Re: A job scheduler for the threads module
by roboticus (Canon) on Dec 24, 2012 at 22:29 UTC

      It was so nice to wake up on Christmas morning and find these replies. Obviously my mistake was not knowing what keywords to use as search strings! (Admittedly, a fairly common mistake when there's more than one way to do it.) In the future, I hope that anyone searching for "thread scheduling" will find this thread.

      BTW, I like your answer a lot more than learnedbyerror's eventual solution, which seems like overkill. I'll use yours as a basis for whatever I come up with and add it to my question.

Re: A job scheduler for the threads module
by BrowserUk (Pope) on Dec 24, 2012 at 23:13 UTC

    Here's one I prepared earlier :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1010230]
Approved by muba
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-11-28 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (200 votes), past polls