mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-29 03:32:49 +01:00
more sensible logging
This commit is contained in:
parent
dd91ce1f39
commit
41f6591ac6
1 changed files with 4 additions and 7 deletions
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from functools import wraps
|
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 time import sleep
|
||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
|
|
||||||
|
@ -43,19 +43,16 @@ def pooled():
|
||||||
A wrapper to run a thread in a thread pool
|
A wrapper to run a thread in a thread pool
|
||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
logging.info('Waiting for function')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
func, args, kwargs = async_queue.get()
|
func, args, kwargs = async_queue.get()
|
||||||
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
logging.debug("Closing run_async thread %s/%d" %
|
||||||
|
(current_thread().getName(), len(async_threads)))
|
||||||
break
|
break
|
||||||
|
|
||||||
logging.info('Got function')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
logging.info('Executed function')
|
|
||||||
|
|
||||||
except:
|
except:
|
||||||
logging.exception("Async function raised exception")
|
logging.exception("Async function raised exception")
|
||||||
|
@ -114,7 +111,7 @@ class Dispatcher(object):
|
||||||
if not len(async_threads):
|
if not len(async_threads):
|
||||||
request.CON_POOL_SIZE = workers + 3
|
request.CON_POOL_SIZE = workers + 3
|
||||||
for i in range(workers):
|
for i in range(workers):
|
||||||
thread = Thread(target=pooled)
|
thread = Thread(target=pooled, name=str(i))
|
||||||
async_threads.add(thread)
|
async_threads.add(thread)
|
||||||
thread.start()
|
thread.start()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue