Staging
v0.5.1
https://github.com/python/cpython
Revision 903f487684c25940c35f9b474c96e309842828c0 authored by Guido van Rossum on 07 October 1995, 19:18:22 UTC, committed by Guido van Rossum on 07 October 1995, 19:18:22 UTC
1 parent 1c45ca3
Raw File
Tip revision: 903f487684c25940c35f9b474c96e309842828c0 authored by Guido van Rossum on 07 October 1995, 19:18:22 UTC
add BGN/END_SAVE macros around fcntl/ioctl calls
Tip revision: 903f487
lockfile.py
import struct, fcntl, FCNTL

def writelock(f):
	_lock(f, FCNTL.F_WRLCK)

def readlock(f):
	_lock(f, FCNTL.F_RDLCK)

def unlock(f):
	_lock(f, FCNTL.F_UNLCK)

def _lock(f, op):
	dummy = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW,
			    struct.pack('2h8l', op,
					0, 0, 0, 0, 0, 0, 0, 0, 0))
back to top