File: more-flexible-wait.patch

package info (click to toggle)
flashproxy 1.7-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 936 kB
  • ctags: 876
  • sloc: python: 3,708; sh: 823; makefile: 246; lisp: 15
file content (31 lines) | stat: -rw-r--r-- 1,324 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Description: Fix build for slower machines
 Use a more flexible wait behaviour in the facilitator test.
Author: Ximin Luo <infinity0@torproject.org>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765156
Applied-Upstream: commit:c89d0c04a6e454c54a58cd17c0b2e7c7267f15fc
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/facilitator/fp-facilitator-test.py
+++ b/facilitator/fp-facilitator-test.py
@@ -209,7 +209,20 @@
         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()