I was challenged (in the CB) to come up with a file based locking mechanism that would solve atcroft's throttling problem. Additionally, I was asked that it
The following is my best stab. It looks a little too short to be correct ... can anyone see problems (and ideally, solutions)? You may want to cf. LockFile::Simple.
$LOCK = $0; $MAX_RUNNING = 10; sub lock_count { return scalar split /\s+/, `fuser $LOCK 2>/dev/null`; } die ("Too many running processes") if (&lock_count >= $MAX_RUNNING); open(LOCK) or die("Failed to acquire lock"); die ("Too many running processes") if (&lock_count > $MAX_RUNNING);
In reply to File Based Throttling by idsfa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |