From: Brett Cannon Date: Sun, 3 Feb 2008 02:43:01 +0000 (+0000) Subject: Use context manager for a lock. X-Git-Tag: v2.6a1~293 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b7deed9a51e34a501f4d9caf1118e16ec2e5e14;p=python Use context manager for a lock. --- diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py index 00348a8ad4..fdee1fac3b 100644 --- a/Lib/test/test_queue.py +++ b/Lib/test/test_queue.py @@ -142,11 +142,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin): if x is None: q.task_done() return - self.cumlock.acquire() - try: + with self.cumlock: self.cum += x - finally: - self.cumlock.release() q.task_done() def queue_join_test(self, q):