Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Submit job to Queue

by Anonymous Monk
on Sep 20, 2001 at 23:35 UTC ( #113744=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl program that runs an external process. The process is a circuit simulator. What I want to do is have multiple jobs put into a queue, and when the process completes, it runs the next file in the queue. This is step- by-step what I want to do:
1. Submit a system() call if that process is not running. 2. if process is already running, put system call in queue. 3. when 1st system call completes, grab next in queue, and run.
Thanks for the help!

Replies are listed 'Best First'.
Re: Submit job to Queue
by blakem (Monsignor) on Sep 20, 2001 at 23:41 UTC
    So, you want to run multiple children in parallel, but be able to control how many are running at any one time (based on some sort of queue structure). This sounds like a job for Parallel::ForkManager.


      I also forgot to mention that multiple people will be submitting these jobs from different instances of the same Perl program. So I think I'll need some text file holding the queue.
        That shouldn't be much of a problem. It divides up nicely into the classic "consumers" and "producers" scenerio. Producers push stuff onto the queue, consumers take things off of it

        First you have several producers (namely people submitting jobs) They dump job requests into a file, making sure they dont step on each others toes using file flocking.

        Then you have the consumers... they consume the job requests. You can either have a single process read the job file and manage a bunch of subprocesses, or have each consumer process deal with fetching its own requests. I'd probably opt for having one manager process that takes care of reading the job queue and handing the requests off to the child processes. This is where Parallel::ForkManager comes in handy.

        So you really have two programs... one used to submit the job request to the queue, and another to read the list and manage the children that will run the requests in parallel. Does that make sense?


Re (tilly) 1: Submit job to Queue
by tilly (Archbishop) on Sep 21, 2001 at 00:05 UTC
    If you are on Linux or some form of Unix, install the at command. Scheduling jobs "at now" puts them into a queue, and if you want you can even give the queues names to have them go into different queues. Bonus: Configure at correctly and anything the job prints is sent as an email.

    If you need something better, I would look search for job control solutions. If you don't find one that suits, you can always use a control table in a relational database for job control. That is more work, but you can allow jobs to be distributed across multiple machines in different locations.

Re: Submit job to Queue
by monk2b (Pilgrim) on Sep 21, 2001 at 20:33 UTC
    What I think you are looking for is a portable batch program.
    There is a gpl one named portable batch system and a commercial
    version named lsf
    learning too

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://113744]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-07-05 00:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found