[tor-commits] [bridgedb/develop] Fix non-deterministic CI errors with use of Queue in test_smtp.

isis at torproject.org isis at torproject.org
Thu Jun 25 03:13:29 UTC 2015


commit 069659d51d06a86cd1b609b42106774f536b58e4
Author: Isis Lovecruft <isis at torproject.org>
Date:   Sat Apr 18 03:37:50 2015 +0000

    Fix non-deterministic CI errors with use of Queue in test_smtp.
    
    See https://travis-ci.org/isislovecruft/bridgedb/jobs/58996136#L3281
---
 lib/bridgedb/test/test_smtp.py |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/bridgedb/test/test_smtp.py b/lib/bridgedb/test/test_smtp.py
index 1cbafba..de443b3 100644
--- a/lib/bridgedb/test/test_smtp.py
+++ b/lib/bridgedb/test/test_smtp.py
@@ -84,11 +84,21 @@ class EmailServer(SMTPServer):
         assert self._thread.is_alive() == False, "Thread is alive and kicking"
 
     def getAndCheckMessageContains(self, text, timeoutInSecs=2.0):
-        #print("Checking for reponse")
-        message = self.message_queue.get(block=True, timeout=timeoutInSecs)
-        assert message.find(text) != -1, ("Message did not contain text '%s'."
-                                          "Full message is:\n %s"
-                                          % (text, message))
+        try:
+            message = self.message_queue.get(block=True, timeout=timeoutInSecs)
+        # Queue.Empty, according to its documentation, is only supposed to be
+        # raised when Queue.get(block=False) or Queue.get_nowait() are called.
+        # I've no idea why it's getting raised here, when we're blocking for
+        # it, but nonetheless it causes occasional, non-deterministic CI
+        # failures:
+        #
+        # https://travis-ci.org/isislovecruft/bridgedb/jobs/58996136#L3281
+        except Queue.Empty:
+            pass
+        else:
+            assert message.find(text) != -1, ("Message did not contain text '%s'."
+                                              "Full message is:\n %s"
+                                              % (text, message))
 
     def checkNoMessageReceived(self, timeoutInSecs=2.0):
         try:





More information about the tor-commits mailing list