home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / pippy-0.6beta-src.tar.gz / pippy-0.6beta-src.tar / pippy-0.6beta-src / src / Lib / lib-old / lockfile.py < prev    next >
Text File  |  2000-12-21  |  288b  |  16 lines

  1. import struct, fcntl, FCNTL
  2.  
  3. def writelock(f):
  4.     _lock(f, FCNTL.F_WRLCK)
  5.  
  6. def readlock(f):
  7.     _lock(f, FCNTL.F_RDLCK)
  8.  
  9. def unlock(f):
  10.     _lock(f, FCNTL.F_UNLCK)
  11.  
  12. def _lock(f, op):
  13.     dummy = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW,
  14.                 struct.pack('2h8l', op,
  15.                     0, 0, 0, 0, 0, 0, 0, 0, 0))
  16.