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