From 076db925c8625b384b3fea13ffc9dc107643bd58 Mon Sep 17 00:00:00 2001 From: Numan Siddique Date: Mon, 24 Feb 2014 16:29:35 +0530 Subject: [PATCH] Fixed the issue for pop exception Fixed the issue so that two threads do not pop the list at the same time Closes-Bug: #1283926 Change-Id: I693407495c18c3e4a0ca2d8d94c4f4ed179371bf --- tests/test_rabbit.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_rabbit.py b/tests/test_rabbit.py index 39afb3ca4..a68069786 100644 --- a/tests/test_rabbit.py +++ b/tests/test_rabbit.py @@ -275,8 +275,11 @@ class TestRacyWaitForReply(test_utils.BaseTestCase): def reply_waiter(self, msg_id, timeout): if wait_conditions: - with wait_conditions[0]: - wait_conditions.pop().wait() + cond = wait_conditions.pop() + with cond: + cond.notify() + with cond: + cond.wait() return orig_reply_waiter(self, msg_id, timeout) self.stubs.Set(amqpdriver.ReplyWaiter, 'wait', reply_waiter) @@ -297,7 +300,9 @@ class TestRacyWaitForReply(test_utils.BaseTestCase): # Start the first guy, receive his message, but delay his polling notify_condition = threading.Condition() wait_conditions.append(notify_condition) - senders[0].start() + with notify_condition: + senders[0].start() + notify_condition.wait() msgs.append(listener.poll()) self.assertEqual(msgs[-1].message, {'tx_id': 0})