diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-06-12 12:15:00 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-06-12 12:15:00 +1200 |
commit | a9c74bcb557ea4bd12a2b7b092edfaf5818f6cd6 (patch) | |
tree | a422ed6ab5a876cf3eadd38e51b9830bfdb70033 /netlib | |
parent | e0d6434b27ed16805a2b306f85fd9de0b7971574 (diff) | |
download | mitmproxy-a9c74bcb557ea4bd12a2b7b092edfaf5818f6cd6.tar.gz mitmproxy-a9c74bcb557ea4bd12a2b7b092edfaf5818f6cd6.tar.bz2 mitmproxy-a9c74bcb557ea4bd12a2b7b092edfaf5818f6cd6.zip |
Start rolling out leak detection in netlib
Diffstat (limited to 'netlib')
-rw-r--r-- | netlib/exceptions.py | 4 | ||||
-rw-r--r-- | netlib/tcp.py | 11 |
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 |