From fec92ea03e41b826e1bd982a11ebcb7a412626ad Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sun, 28 Dec 2014 13:36:03 +0100 Subject: [PATCH] Potential fix for #2055 --- headphones/lock.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/headphones/lock.py b/headphones/lock.py index 2fcc7ab7..1ec3f2c8 100644 --- a/headphones/lock.py +++ b/headphones/lock.py @@ -39,12 +39,12 @@ class TimedLock(object): sleep_amount = self.minimum_delta - delta if sleep_amount >= 0: # zero sleeps give the cpu a chance to task-switch - headphones.logger.info('Sleeping %s (interval)', sleep_amount) + headphones.logger.debug('Sleeping %s (interval)', sleep_amount) time.sleep(sleep_amount) while not self.queue.empty(): try: seconds = self.queue.get(False) - headphones.logger.info('Sleeping %s (queued)', seconds) + headphones.logger.debug('Sleeping %s (queued)', seconds) time.sleep(seconds) except Queue.Empty: continue @@ -59,15 +59,14 @@ class TimedLock(object): def snooze(self, seconds): """ - Asynchronously add time to the next request. - Can be called outside + Asynchronously add time to the next request. Can be called outside of the lock context, but it is possible for the next lock holder to not check the queue until after something adds time to it. """ - # we use a queue so that we don't have to synchronize + # We use a queue so that we don't have to synchronize # across threads and with or without locks headphones.logger.info('Adding %s to queue', seconds) - self.queue.add(seconds) + self.queue.put(seconds) class FakeLock(object):