Commit 2a6be4be authored by Jeremy Hylton's avatar Jeremy Hylton

Log error if we fail to lock file.

parent 2fc2930f
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
import os import os
import errno import errno
import logging
try: try:
import fcntl import fcntl
...@@ -45,6 +46,7 @@ else: ...@@ -45,6 +46,7 @@ else:
# File is automatically unlocked on close # File is automatically unlocked on close
pass pass
log = logging.getLogger("LockFile")
# This is a better interface to use than the lockfile.lock_file() interface. # This is a better interface to use than the lockfile.lock_file() interface.
...@@ -59,7 +61,11 @@ class LockFile: ...@@ -59,7 +61,11 @@ class LockFile:
if e.errno <> errno.ENOENT: raise if e.errno <> errno.ENOENT: raise
self._fp = open(path, 'w+') self._fp = open(path, 'w+')
# Acquire the lock and piss on the hydrant # Acquire the lock and piss on the hydrant
try:
lock_file(self._fp) lock_file(self._fp)
except:
log.exception("Error locking file %s" % path)
raise
print >> self._fp, os.getpid() print >> self._fp, os.getpid()
self._fp.flush() self._fp.flush()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment