From 09edbd9492e59c0c8dcae69b4b1f4b745867abe4 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 11 Jun 2016 19:52:24 +1200 Subject: Improve debugging of thread and other leaks - Add basethread.BaseThread that all threads outside of test suites should use - Add a signal handler to mitmproxy, mitmdump and mitmweb that dumps resource information to screen when SIGUSR1 is received. - Improve thread naming throughout to make thread dumps understandable --- netlib/basethread.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 netlib/basethread.py (limited to 'netlib/basethread.py') diff --git a/netlib/basethread.py b/netlib/basethread.py new file mode 100644 index 00000000..7963eb7e --- /dev/null +++ b/netlib/basethread.py @@ -0,0 +1,14 @@ +import time +import threading + + +class BaseThread(threading.Thread): + def __init__(self, name, *args, **kwargs): + super(BaseThread, self).__init__(name=name, *args, **kwargs) + self._thread_started = time.time() + + def _threadinfo(self): + return "%s - age: %is" % ( + self.name, + int(time.time() - self._thread_started) + ) -- cgit v1.2.3