mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Do not acquire lock on systems without fcntl
This commit is contained in:
parent
794b1cf4e6
commit
8a99834747
1 changed files with 13 additions and 10 deletions
|
@ -15,7 +15,6 @@ Package support for openSUSE via the zypper package manager
|
|||
import configparser
|
||||
import datetime
|
||||
import errno
|
||||
import fcntl
|
||||
import fnmatch
|
||||
import logging
|
||||
import os
|
||||
|
@ -39,6 +38,9 @@ import salt.utils.versions
|
|||
from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationError
|
||||
from salt.utils.versions import LooseVersion
|
||||
|
||||
if salt.utils.files.is_fcntl_available():
|
||||
import fcntl
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
HAS_ZYPP = False
|
||||
|
@ -247,15 +249,16 @@ class _Zypper:
|
|||
"""
|
||||
Is this an RPM lock error?
|
||||
"""
|
||||
if self.exit_code > 0 and os.path.exists(self.RPM_LOCK):
|
||||
with salt.utils.files.fopen(self.RPM_LOCK, mode="w+") as rfh:
|
||||
try:
|
||||
fcntl.lockf(rfh, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except OSError as err:
|
||||
if err.errno == errno.EAGAIN:
|
||||
return True
|
||||
else:
|
||||
fcntl.lockf(rfh, fcntl.LOCK_UN)
|
||||
if salt.utils.files.is_fcntl_available():
|
||||
if self.exit_code > 0 and os.path.exists(self.RPM_LOCK):
|
||||
with salt.utils.files.fopen(self.RPM_LOCK, mode="w+") as rfh:
|
||||
try:
|
||||
fcntl.lockf(rfh, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except OSError as err:
|
||||
if err.errno == errno.EAGAIN:
|
||||
return True
|
||||
else:
|
||||
fcntl.lockf(rfh, fcntl.LOCK_UN)
|
||||
|
||||
return False
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue