A simple lock solution
def __init__(self, filename):
# auto-unlock when lock object is deleted
# for a big production with timeouts,
# see the Mailman source code (LockFile.py);
# it works on all Unixes and supports NFS;
# and the code is very complex...