diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-02-07 10:00:37 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-02-14 14:56:28 -0500 |
commit | ff0048a3a26c9076c8052a8c7be171e4364f0d09 (patch) | |
tree | 71d260915f46d65ae2794ab22dbe32181bd5d05f /src/lib/Bcfg2/Client/Client.py | |
parent | 9d0e6991fc23c073efc0db6bf10e1081f6725e55 (diff) | |
download | bcfg2-ff0048a3a26c9076c8052a8c7be171e4364f0d09.tar.gz bcfg2-ff0048a3a26c9076c8052a8c7be171e4364f0d09.tar.bz2 bcfg2-ff0048a3a26c9076c8052a8c7be171e4364f0d09.zip |
moved common file locking code into Bcfg2.Utils
Diffstat (limited to 'src/lib/Bcfg2/Client/Client.py')
-rw-r--r-- | src/lib/Bcfg2/Client/Client.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Client/Client.py b/src/lib/Bcfg2/Client/Client.py index 45e0b64e6..b0d877a19 100644 --- a/src/lib/Bcfg2/Client/Client.py +++ b/src/lib/Bcfg2/Client/Client.py @@ -14,6 +14,7 @@ import Bcfg2.Options import Bcfg2.Client.XML import Bcfg2.Client.Frame import Bcfg2.Client.Tools +from Bcfg2.Utils import locked from Bcfg2.Compat import xmlrpclib from Bcfg2.version import __version__ from subprocess import Popen, PIPE @@ -288,11 +289,7 @@ class Client(object): #check lock here try: lockfile = open(self.setup['lockfile'], 'w') - try: - fcntl.lockf(lockfile.fileno(), - fcntl.LOCK_EX | fcntl.LOCK_NB) - except IOError: - # otherwise exit and give a warning to the user + if locked(lockfile.fileno()): self.fatal_error("Another instance of Bcfg2 is running. " "If you want to bypass the check, run " "with the %s option" % @@ -301,7 +298,8 @@ class Client(object): raise except: lockfile = None - self.logger.error("Failed to open lockfile") + self.logger.error("Failed to open lockfile %s: %s" % + (self.setup['lockfile'], sys.exc_info()[1])) # execute the configuration self.tools.Execute() |