Wait until next version.. it'll provide you a fancy locking api (if I remember to implement it

)
You can expect it to work as following:
lock -wait "lockname" <timeout/milliseconds>
lock -release "lockname"
lock will return 0 on success, 1 on timeout & tcl error on system error.