mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 11:57:37 -02:30
Use lockf, not flock.
This performs more reliably on certain filesystems in Linux.
This commit is contained in:
@@ -1834,9 +1834,9 @@ class RunProjectUpdate(BaseTask):
|
||||
|
||||
def release_lock(self, instance):
|
||||
try:
|
||||
fcntl.flock(self.lock_fd, fcntl.LOCK_UN)
|
||||
fcntl.lockf(self.lock_fd, fcntl.LOCK_UN)
|
||||
except IOError as e:
|
||||
logger.error("I/O error({0}) while trying to open lock file [{1}]: {2}".format(e.errno, instance.get_lock_file(), e.strerror))
|
||||
logger.error("I/O error({0}) while trying to release lock file [{1}]: {2}".format(e.errno, instance.get_lock_file(), e.strerror))
|
||||
os.close(self.lock_fd)
|
||||
raise
|
||||
|
||||
@@ -1852,7 +1852,7 @@ class RunProjectUpdate(BaseTask):
|
||||
raise RuntimeError(u'Invalid lock file path')
|
||||
|
||||
try:
|
||||
self.lock_fd = os.open(lock_path, os.O_RDONLY | os.O_CREAT)
|
||||
self.lock_fd = os.open(lock_path, os.O_RDWR | os.O_CREAT)
|
||||
except OSError as e:
|
||||
logger.error("I/O error({0}) while trying to open lock file [{1}]: {2}".format(e.errno, lock_path, e.strerror))
|
||||
raise
|
||||
@@ -1864,7 +1864,7 @@ class RunProjectUpdate(BaseTask):
|
||||
if instance.cancel_flag:
|
||||
logger.debug("ProjectUpdate({0}) was cancelled".format(instance.pk))
|
||||
return
|
||||
fcntl.flock(self.lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
fcntl.lockf(self.lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
break
|
||||
except IOError as e:
|
||||
if e.errno not in (errno.EAGAIN, errno.EACCES):
|
||||
|
||||
Reference in New Issue
Block a user