From fcaaa7b09bed13a5bc913e80d3ab03f264ec7be9 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Thu, 5 Nov 2015 02:29:15 +0000 Subject: [PATCH] include tid in thread name for more threads (linux only) for correlation with top -H --- warcprox/mitmproxy.py | 3 +++ warcprox/writerthread.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/warcprox/mitmproxy.py b/warcprox/mitmproxy.py index 3c3f95b..532c221 100644 --- a/warcprox/mitmproxy.py +++ b/warcprox/mitmproxy.py @@ -15,11 +15,14 @@ except ImportError: import socket import logging import ssl +import warcprox +import threading class MitmProxyHandler(http_server.BaseHTTPRequestHandler): logger = logging.getLogger("warcprox.mitmproxy.MitmProxyHandler") def __init__(self, request, client_address, server): + threading.current_thread.name = 'MitmProxyHandler-thread(tid={})'.format(warcprox.gettid()) self.is_connect = False self._headers_buffer = [] http_server.BaseHTTPRequestHandler.__init__(self, request, client_address, server) diff --git a/warcprox/writerthread.py b/warcprox/writerthread.py index f0c7d25..c69e514 100644 --- a/warcprox/writerthread.py +++ b/warcprox/writerthread.py @@ -41,7 +41,7 @@ class WarcWriterThread(threading.Thread): def _run(self): while not self.stop.is_set(): try: - self.setName('WarcWriterThread(tid={})'.format(warcprox.gettid())) + self.name = 'WarcWriterThread(tid={})'.format(warcprox.gettid()) while True: try: recorded_url = self.recorded_url_q.get(block=True, timeout=0.5)