Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Locking/unlocking program execution using a queue

by RazorbladeBidet (Friar)
on Mar 30, 2005 at 15:59 UTC ( [id://443528]=note: print w/replies, xml ) Need Help??


in reply to Re: Locking/unlocking program execution using a queue
in thread Locking/unlocking program execution using a queue

Yes, I'd considered using a database, but I wanted to avoid it if possible. Plus it's too easy :) I would imagine the I/O overhead for the files (and shell overhead for execution) would be more than the DB overhead (plus I'm already using a DB, so the connection overhead is already accounted for).

There are certain things in memory of that particular process (command line parameters, time of execution, etc.) that require me to keep the process around (sleeping) - I could write all necessary things out, but... that sounds too complicated and less maintainable... so I'm thinking:
  1. Create a queue file w/ PID ($$.queue)
  2. Get oldest queue file (ls -rt | head -1)
  3. Check to see if that process is running (kill 0 $file)
  4. If not running, remove $file and repeat step 2
  5. If running, is $file == $$?
  6. If not, sleep for a while, then go to step 3.
How does that sound?
--------------
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."
  • Comment on Re^2: Locking/unlocking program execution using a queue

Replies are listed 'Best First'.
Re^3: Locking/unlocking program execution using a queue
by gam3 (Curate) on Mar 30, 2005 at 23:41 UTC
    There is a major problem here if two processes start in the same second (that is have the same timestamp).
    -- gam3
    A picture is worth a thousand words, but takes 200K.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 07:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found