aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2016-06-14 17:11:41 +1200
committerGitHub <noreply@github.com>2016-06-14 17:11:41 +1200
commit04394ebd503fc26d9a4bcb201607b9dd3af157fa (patch)
tree9553d0f45e705da04bfa4be8dd5e39d09fcd112f /netlib
parentd8ae2f156203a81a8e6d325f5c460c351cfbfc5c (diff)
parent93276d45be68790b5f4aeb4577c380ca1608efb3 (diff)
downloadmitmproxy-04394ebd503fc26d9a4bcb201607b9dd3af157fa.tar.gz
mitmproxy-04394ebd503fc26d9a4bcb201607b9dd3af157fa.tar.bz2
mitmproxy-04394ebd503fc26d9a4bcb201607b9dd3af157fa.zip
Merge pull request #1251 from cortesi/netlibrace
Roll connect handlers and thread leak detection out in more of the netlib test suite
Diffstat (limited to 'netlib')
-rw-r--r--netlib/exceptions.py4
-rw-r--r--netlib/tcp.py11
2 files changed, 15 insertions, 0 deletions
diff --git a/netlib/exceptions.py b/netlib/exceptions.py
index 05f1054b..dec79c22 100644
--- a/netlib/exceptions.py
+++ b/netlib/exceptions.py
@@ -54,3 +54,7 @@ class TlsException(NetlibException):
class InvalidCertificateException(TlsException):
pass
+
+
+class Timeout(TcpException):
+ pass
diff --git a/netlib/tcp.py b/netlib/tcp.py
index a8a68139..69dafc1f 100644
--- a/netlib/tcp.py
+++ b/netlib/tcp.py
@@ -967,3 +967,14 @@ class TCPServer(object):
"""
Called after server shutdown.
"""
+
+ def wait_for_silence(self, timeout=5):
+ start = time.time()
+ while 1:
+ if time.time() - start >= timeout:
+ raise exceptions.Timeout(
+ "%s service threads still alive" %
+ self.handler_counter.count
+ )
+ if self.handler_counter.count == 0:
+ return