#!/usr/bin/env python
#
# We have to mount the same share to test, test1, test2 directories that locate in the directory we
# execute this script from.

from os import open, close, O_RDWR, O_CREAT, write, read, O_RDONLY, O_WRONLY, O_TRUNC, lseek, SEEK_END, SEEK_SET
from fcntl import lockf, LOCK_EX

f = open('test/_test4321_', O_RDWR | O_CREAT | O_TRUNC)
close(f)

f1 = open('test1/_test4321_', O_WRONLY)
lockf(f1, LOCK_EX, 1, 0)
write(f1, 'a')

f2 = open('test2/_test4321_', O_RDONLY)
print read(f2, 1)

close(f1)
close(f2)
