add thread name to log message prefix to trace across Protocol.deliver threads

pull/668/head
Ryan Barrett 2023-10-10 10:13:57 -07:00
rodzic 5bf081afdb
commit f002b536d9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -21,6 +21,11 @@ logger = logging.getLogger(__name__)
# logging.getLogger('lexrpc').setLevel(logging.INFO)
logging.getLogger('negotiator').setLevel(logging.WARNING)
# add thread name to log prefix so we can trace log messages in
# Protocol.deliver, which is parallelized across threads
logging.getLogger().handlers[0].setFormatter(
logging.Formatter(fmt='%(levelname)s:%(name)s:%(threadName)s:%(message)s'))
app_dir = Path(__file__).parent

Wyświetl plik

@ -824,7 +824,8 @@ class Protocol:
errors = [] # stores (target URL, code, body) tuples
# deliver to all targets, in parallel, with a thread pool
with ThreadPoolExecutor(max_workers=DELIVER_THREADS) as executor:
with ThreadPoolExecutor(max_workers=DELIVER_THREADS,
thread_name_prefix='deliver') as executor:
results = []
for target, orig_obj in sorted_targets: