Locking files in recorder

Sometimes you need to find out which recorded files are ready for processing and which are still being recorded. A new feature record_lock makes that possible.

recorder myrec {
               record all;
               record_interval 30s;
               record_path /tmp/rec;
               record_unique on;
               record_lock on;

File being recorded is exclusively locked with fcntl lock engine. You can easily check file lock status from elsewhere. On FreeBSD you can use flock tool to check that. On Linux flock and fcntl are unrelated so you’re left with writing a simple script. Here’s an example of isunlocked.py.


import fcntl, sys

fcntl.lockf(open(sys.argv[1], "a"), fcntl.LOCK_EX|fcntl.LOCK_NB)

Use this script to check if file is currently being recorded.

for file in /tmp/rec/*; do
    printf "$file : ";
    if ~/isunlocked.py $file; then echo "ready"; else echo "locked"; fi;

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: