mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-02-16 18:31:45 +01:00
fix race condition in dispatcher
This commit is contained in:
parent
fc64cc0a4a
commit
b78ceeed10
1 changed files with 4 additions and 1 deletions
|
@ -26,6 +26,7 @@ from functools import wraps
|
||||||
from inspect import getargspec
|
from inspect import getargspec
|
||||||
from threading import Thread, BoundedSemaphore, Lock
|
from threading import Thread, BoundedSemaphore, Lock
|
||||||
from re import match
|
from re import match
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from telegram import (TelegramError, Update, NullHandler)
|
from telegram import (TelegramError, Update, NullHandler)
|
||||||
|
|
||||||
|
@ -175,6 +176,7 @@ class Dispatcher:
|
||||||
update = self.update_queue.get()
|
update = self.update_queue.get()
|
||||||
|
|
||||||
if type(update) is self._Stop:
|
if type(update) is self._Stop:
|
||||||
|
self.running = False
|
||||||
break
|
break
|
||||||
|
|
||||||
self.processUpdate(update)
|
self.processUpdate(update)
|
||||||
|
@ -200,8 +202,9 @@ class Dispatcher:
|
||||||
"""
|
"""
|
||||||
with self.__lock:
|
with self.__lock:
|
||||||
if self.running:
|
if self.running:
|
||||||
self.running = False
|
|
||||||
self.update_queue.put(self._Stop())
|
self.update_queue.put(self._Stop())
|
||||||
|
while self.running:
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
def processUpdate(self, update):
|
def processUpdate(self, update):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue