include tid in thread name for more threads (linux only) for correlation with top -H

This commit is contained in:
Noah Levitt 2015-11-05 02:29:15 +00:00
parent a9fc550453
commit fcaaa7b09b
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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)