[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] use a more flexible wait time in the facilitator test, to work on slower machines



commit c89d0c04a6e454c54a58cd17c0b2e7c7267f15fc
Author: Ximin Luo <infinity0@xxxxxxxxxxxxxx>
Date:   Sun Nov 2 19:33:55 2014 +0000

    use a more flexible wait time in the facilitator test, to work on slower machines
---
 facilitator/fp-facilitator-test.py |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/facilitator/fp-facilitator-test.py b/facilitator/fp-facilitator-test.py
index 9de44d3..8c008a7 100755
--- a/facilitator/fp-facilitator-test.py
+++ b/facilitator/fp-facilitator-test.py
@@ -209,7 +209,20 @@ class FacilitatorProcTest(unittest.TestCase):
         self.relay_file.seek(0)
         fn = os.path.join(os.path.dirname(__file__), "./fp-facilitator")
         self.process = subprocess.Popen(["python", fn, "-d", "-p", str(FACILITATOR_PORT), "-r", self.relay_file.name, "-l", "/dev/null"])
-        time.sleep(0.1)
+        self.waitForChild()
+
+    def waitForChild(self):
+        """Wait until the child process is responsive. This takes different
+        times on different machines so be flexible in how long to wait. e.g.
+        see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765156""";
+        for i in xrange(0, 20):
+            try:
+                s = fac.fac_socket(FACILITATOR_ADDR)
+                s.close()
+                return
+            except socket.error as e:
+                time.sleep(0.05)
+        raise e
 
     def tearDown(self):
         ret = self.process.poll()

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits