<|file_name|>testLock2.py<|end_file_name|><｜fim▁begin｜>"""import portalocker

with portalocker.Lock('text.txt', timeout=5) as fh:
    fh.write("Sono in testLoxk2.py")
"""
from lockfile import LockFile
<｜fim▁hole｜>with lock:
    print lock.path, 'is locked.'
    with open('text.txt', "a") as file:
        file.write("Sono in testLock2.py")<｜fim▁end｜>
lock = LockFile('text.txt')