From c5076f5e019b73ec2f6efea5a4bafed90423df8f Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 3 Jun 2016 11:47:07 +1200 Subject: Implement a service connection handler counter, use it in Pathod test suite Lots of failures, but that's a good thing. --- pathod/test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pathod') diff --git a/pathod/test.py b/pathod/test.py index 32b37731..b10e9229 100644 --- a/pathod/test.py +++ b/pathod/test.py @@ -7,6 +7,10 @@ from six.moves import queue from . import pathod +class TimeoutError(Exception): + pass + + class Daemon: IFACE = "127.0.0.1" @@ -40,6 +44,17 @@ class Daemon: def text_log(self): return self.logfp.getvalue() + def wait_for_silence(self, timeout=5): + start = time.time() + while 1: + if time.time() - start >= timeout: + raise TimeoutError( + "%s service threads still alive" % + self.thread.server.counter.count + ) + if self.thread.server.counter.count == 0: + return + def expect_log(self, n, timeout=5): l = [] start = time.time() -- cgit v1.2.3