From 41f6591ac69b5e79306ffc9552ac06267e6e1044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Mon, 30 May 2016 17:12:27 +0200 Subject: [PATCH] more sensible logging --- telegram/ext/dispatcher.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/telegram/ext/dispatcher.py b/telegram/ext/dispatcher.py index 72f206236..fd6fc58c3 100644 --- a/telegram/ext/dispatcher.py +++ b/telegram/ext/dispatcher.py @@ -20,7 +20,7 @@ import logging from functools import wraps -from threading import Thread, Lock, Event # , current_thread +from threading import Thread, Lock, Event, current_thread from time import sleep from queue import Queue, Empty @@ -43,19 +43,16 @@ def pooled(): A wrapper to run a thread in a thread pool """ while True: - logging.info('Waiting for function') - try: func, args, kwargs = async_queue.get() except TypeError: + logging.debug("Closing run_async thread %s/%d" % + (current_thread().getName(), len(async_threads))) break - logging.info('Got function') - try: func(*args, **kwargs) - logging.info('Executed function') except: logging.exception("Async function raised exception") @@ -114,7 +111,7 @@ class Dispatcher(object): if not len(async_threads): request.CON_POOL_SIZE = workers + 3 for i in range(workers): - thread = Thread(target=pooled) + thread = Thread(target=pooled, name=str(i)) async_threads.add(thread) thread.start() else: