From: Alfredo Deza Date: Mon, 30 Mar 2015 17:13:16 +0000 (-0400) Subject: use dev_log for locking and unlocking of shards X-Git-Tag: v1.2.2~3^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28%2Fhead;p=radosgw-agent.git use dev_log for locking and unlocking of shards Signed-off-by: Alfredo Deza --- diff --git a/radosgw_agent/lock.py b/radosgw_agent/lock.py index 2036f8e..d3d45e0 100644 --- a/radosgw_agent/lock.py +++ b/radosgw_agent/lock.py @@ -3,18 +3,24 @@ import threading import time from radosgw_agent import client +from radosgw_agent.util import get_dev_logger log = logging.getLogger(__name__) +dev_log = get_dev_logger(__name__) + class LockBroken(Exception): pass + class LockRenewFailed(LockBroken): pass + class LockExpired(LockBroken): pass + class Lock(threading.Thread): """A lock on a shard log that automatically refreshes itself. @@ -39,7 +45,7 @@ class Lock(threading.Thread): self.failed = False def set_shard(self, shard_num): - log.debug('set_shard to %d', shard_num) + dev_log.debug('set_shard to %d', shard_num) with self.lock: assert self.shard_num is None, \ 'attempted to acquire new lock without releasing old one' @@ -48,7 +54,7 @@ class Lock(threading.Thread): self.shard_num = shard_num def unset_shard(self): - log.debug('unset shard') + dev_log.debug('unset shard') with self.lock: self.shard_num = None @@ -58,7 +64,7 @@ class Lock(threading.Thread): The old lock must have already been released if shard_num is specified. client.NotFound may be raised if the log contains no entries. """ - log.debug('acquire lock') + dev_log.debug('acquire lock') with self.lock: self._acquire() @@ -76,7 +82,7 @@ class Lock(threading.Thread): were any errors renewing the current lock or if it expired. If the lock was not sustained, raise LockAcquireFailed or LockExpired. """ - log.debug('release and clear lock') + dev_log.debug('release and clear lock') with self.lock: shard_num = self.shard_num self.shard_num = None