|
|
@ -2190,18 +2190,15 @@ else:
|
|
|
|
import fcntl
|
|
|
|
import fcntl
|
|
|
|
|
|
|
|
|
|
|
|
def _lock_file(f, exclusive, block):
|
|
|
|
def _lock_file(f, exclusive, block):
|
|
|
|
|
|
|
|
flags = fcntl.LOCK_EX if exclusive else fcntl.LOCK_SH
|
|
|
|
|
|
|
|
if not block:
|
|
|
|
|
|
|
|
flags |= fcntl.LOCK_NB
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
fcntl.flock(f,
|
|
|
|
fcntl.flock(f, flags)
|
|
|
|
fcntl.LOCK_SH if not exclusive
|
|
|
|
|
|
|
|
else fcntl.LOCK_EX if block
|
|
|
|
|
|
|
|
else fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
|
|
|
|
|
|
except BlockingIOError:
|
|
|
|
except BlockingIOError:
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
except OSError: # AOSP does not have flock()
|
|
|
|
except OSError: # AOSP does not have flock()
|
|
|
|
fcntl.lockf(f,
|
|
|
|
fcntl.lockf(f, flags)
|
|
|
|
fcntl.LOCK_SH if not exclusive
|
|
|
|
|
|
|
|
else fcntl.LOCK_EX if block
|
|
|
|
|
|
|
|
else fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _unlock_file(f):
|
|
|
|
def _unlock_file(f):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|