Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Ways to sequence calls from multiple processes

by TedPride (Priest)
on Nov 28, 2004 at 14:19 UTC ( [id://410799]=note: print w/replies, xml ) Need Help??


in reply to Ways to sequence calls from multiple processes

I've tested flock on my webhoster, and if two processes try to simultaneously flock, the second one will wait until the first one has ended its lock before starting its own. The best way to do this is like originally suggested -

Open and lock a file (should be different from the file to be processed, so you can open and close that file multiple times if necessary without ending the lock)
Open file to be processed and do whatever
Unlock the lock file

I wrote myself small subs for locking and unlocking, and I just cut and paste them in wherever I need them. Saves time coding.

Replies are listed 'Best First'.
Re^2: Ways to sequence calls from multiple processes
by DrHyde (Prior) on Nov 30, 2004 at 09:07 UTC
    Rather than cutting and pasting code, I strongly recommend moving it into a module which is then used by all your scripts. This means that if you find a bug, you can fix it for all scripts in one place rather than have to edit them all (and I bet you'd miss one here or there). It also means that if for any reason you need to rewrite it because you've moved your code to a different platform or different filesystem where locking semantics are different, you again have to only edit it in one place.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-28 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found