locking: Make parameter to condition's wait() positional
authorMichael Hanselmann <hansmi@google.com>
Fri, 6 May 2011 12:46:29 +0000 (14:46 +0200)
committerMichael Hanselmann <hansmi@google.com>
Mon, 9 May 2011 15:33:46 +0000 (17:33 +0200)
It is always used in the locking code. Unittests are updated.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/locking.py
test/ganeti.locking_unittest.py

index c1e4cd0..5ac9ebe 100644 (file)
@@ -247,7 +247,7 @@ class SingleNotifyPipeCondition(_BaseCondition):
       self._write_fd = None
     self._poller = None
 
-  def wait(self, timeout=None):
+  def wait(self, timeout):
     """Wait for a notification.
 
     @type timeout: float or None
@@ -314,7 +314,7 @@ class PipeCondition(_BaseCondition):
     self._waiters = set()
     self._single_condition = self._single_condition_class(self._lock)
 
-  def wait(self, timeout=None):
+  def wait(self, timeout):
     """Wait for a notification.
 
     @type timeout: float or None
index b17e7e8..b6f80ed 100755 (executable)
@@ -99,7 +99,7 @@ class _ConditionTestCase(_ThreadedTestCase):
 
   def _testAcquireRelease(self):
     self.assertFalse(self.cond._is_owned())
-    self.assertRaises(RuntimeError, self.cond.wait)
+    self.assertRaises(RuntimeError, self.cond.wait, None)
     self.assertRaises(RuntimeError, self.cond.notifyAll)
 
     self.cond.acquire()
@@ -109,7 +109,7 @@ class _ConditionTestCase(_ThreadedTestCase):
     self.cond.release()
 
     self.assertFalse(self.cond._is_owned())
-    self.assertRaises(RuntimeError, self.cond.wait)
+    self.assertRaises(RuntimeError, self.cond.wait, None)
     self.assertRaises(RuntimeError, self.cond.notifyAll)
 
   def _testNotification(self):
@@ -125,7 +125,7 @@ class _ConditionTestCase(_ThreadedTestCase):
     self._addThread(target=_NotifyAll)
     self.assertEqual(self.done.get(True, 1), "NE")
     self.assertRaises(Queue.Empty, self.done.get_nowait)
-    self.cond.wait()
+    self.cond.wait(None)
     self.assertEqual(self.done.get(True, 1), "NA")
     self.assertEqual(self.done.get(True, 1), "NN")
     self.assert_(self.cond._is_owned())
@@ -154,7 +154,7 @@ class TestSingleNotifyPipeCondition(_ConditionTestCase):
   def testNoNotifyReuse(self):
     self.cond.acquire()
     self.cond.notifyAll()
-    self.assertRaises(RuntimeError, self.cond.wait)
+    self.assertRaises(RuntimeError, self.cond.wait, None)
     self.assertRaises(RuntimeError, self.cond.notifyAll)
     self.cond.release()
 
@@ -220,7 +220,7 @@ class TestPipeCondition(_ConditionTestCase):
     def _BlockingWait():
       self.cond.acquire()
       self.done.put("A")
-      self.cond.wait()
+      self.cond.wait(None)
       self.cond.release()
       self.done.put("W")