diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-06-12 12:15:00 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-06-14 14:32:18 +1200 |
commit | e6fd98bb72e5dee899678c0a382c832580f75e82 (patch) | |
tree | 04e5008ce1b27cd8165678b4eed4542d7620d7f7 /netlib/tcp.py | |
parent | ccf4723505935f759c1bff5c5cc7d6d986726422 (diff) | |
download | mitmproxy-e6fd98bb72e5dee899678c0a382c832580f75e82.tar.gz mitmproxy-e6fd98bb72e5dee899678c0a382c832580f75e82.tar.bz2 mitmproxy-e6fd98bb72e5dee899678c0a382c832580f75e82.zip |
Start rolling out leak detection in netlib
Diffstat (limited to 'netlib/tcp.py')
-rw-r--r-- | netlib/tcp.py | 11 |
1 files changed, 11 insertions, 0 deletions
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 |