Skip to content

Commit 78f9bdc

Browse files
committed
dispatcher: pep8 style fix
globals are supposed to be upper case
1 parent 1ff348a commit 78f9bdc

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

telegram/ext/dispatcher.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@
3131

3232
logging.getLogger(__name__).addHandler(NullHandler())
3333

34-
async_queue = Queue()
35-
async_threads = set()
34+
ASYNC_QUEUE = Queue()
35+
ASYNC_THREADS = set()
3636
""":type: set[Thread]"""
37-
async_lock = Lock()
37+
ASYNC_LOCK = Lock()
3838
DEFAULT_GROUP = 0
3939

4040

41-
def pooled():
41+
def _pooled():
4242
"""
4343
A wrapper to run a thread in a thread pool
4444
"""
4545
while True:
4646
try:
47-
func, args, kwargs = async_queue.get()
47+
func, args, kwargs = ASYNC_QUEUE.get()
4848

4949
except TypeError:
5050
logging.debug("Closing run_async thread %s/%d" %
51-
(current_thread().getName(), len(async_threads)))
51+
(current_thread().getName(), len(ASYNC_THREADS)))
5252
break
5353

5454
try:
@@ -77,7 +77,7 @@ def async_func(*pargs, **kwargs):
7777
"""
7878
A wrapper to run a function in a thread
7979
"""
80-
async_queue.put((func, pargs, kwargs))
80+
ASYNC_QUEUE.put((func, pargs, kwargs))
8181

8282
return async_func
8383

@@ -108,13 +108,13 @@ def __init__(self, bot, update_queue, workers=4, exception_event=None):
108108
self.__stop_event = Event()
109109
self.__exception_event = exception_event or Event()
110110

111-
if not len(async_threads):
111+
if not len(ASYNC_THREADS):
112112
if request._CON_POOL:
113113
self.logger.warning("Connection Pool already initialized!")
114114
request.CON_POOL_SIZE = workers + 3
115115
for i in range(workers):
116-
thread = Thread(target=pooled, name=str(i))
117-
async_threads.add(thread)
116+
thread = Thread(target=_pooled, name=str(i))
117+
ASYNC_THREADS.add(thread)
118118
thread.start()
119119
else:
120120
self.logger.debug('Thread pool already initialized, skipping.')

telegram/ext/updater.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,12 @@ def _stop_dispatcher(self):
372372
self.dispatcher.stop()
373373

374374
def _join_async_threads(self):
375-
with dispatcher.async_lock:
376-
threads = list(dispatcher.async_threads)
375+
with dispatcher.ASYNC_LOCK:
376+
threads = list(dispatcher.ASYNC_THREADS)
377377
total = len(threads)
378378

379379
for i in range(total):
380-
dispatcher.async_queue.put(0)
380+
dispatcher.ASYNC_QUEUE.put(0)
381381

382382
for i, thr in enumerate(threads):
383383
self.logger.debug('Waiting for async thread {0}/{1} to end'.format(i, total))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy