in reply to Locking a script

If it is a 'short period of time', you don't want to lock the whole script, surely, just check whether a lockfile exists/is locked before you enter your critical regeion, and if it is, wait in some fashion for it to come free.