Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

one script at a time (race condition)

by david2008 (Scribe)
on Mar 05, 2013 at 16:36 UTC ( #1021866=perlquestion: print w/ replies, xml ) Need Help??
david2008 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have a group of scripts a.pl ... n.pl.
In each of these script i have section which makes a certain reset of the data base and then make a run.
When 2 of these scripts run together i get a messy result.
How can i restrict that just one process runs at a time ?
It would be sufficient for me that when a.pl runs and i try to run b.pl, that b.pl will die.
How can i achieve this ?

Thanks, David

Comment on one script at a time (race condition)
Re: one script at a time (race condition)
by Anonymous Monk on Mar 05, 2013 at 16:45 UTC
      Thanks.
      This solved the issue.
Re: one script at a time (race condition)
by roboticus (Canon) on Mar 05, 2013 at 17:42 UTC

    david2008:

    I see you already have your problem solved. I wanted to mention, though, that instead of using a file, you could use the database itself. At the start of the run, check whether a lock entry exists in the table. If not, add an entry to the table. Do it in a transaction so you can avoid any race conditions. Then, when the run ends, delete the entry.

    I only mention it because you're already pounding on the database.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1021866]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-10-23 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (123 votes), past polls