2001-05-10 12:33:31 -03:00
|
|
|
import struct, fcntl
|
1994-05-03 11:46:18 -03:00
|
|
|
|
|
|
|
def writelock(f):
|
2004-07-18 03:16:08 -03:00
|
|
|
_lock(f, fcntl.F_WRLCK)
|
1994-05-03 11:46:18 -03:00
|
|
|
|
|
|
|
def readlock(f):
|
2004-07-18 03:16:08 -03:00
|
|
|
_lock(f, fcntl.F_RDLCK)
|
1994-05-03 11:46:18 -03:00
|
|
|
|
|
|
|
def unlock(f):
|
2004-07-18 03:16:08 -03:00
|
|
|
_lock(f, fcntl.F_UNLCK)
|
1994-05-03 11:46:18 -03:00
|
|
|
|
|
|
|
def _lock(f, op):
|
2004-07-18 03:16:08 -03:00
|
|
|
dummy = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW,
|
|
|
|
struct.pack('2h8l', op,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0))
|