diff --git a/docs/source/start/Installation.rst b/docs/source/start/Installation.rst index 7886f1d4..efebac5a 100644 --- a/docs/source/start/Installation.rst +++ b/docs/source/start/Installation.rst @@ -82,7 +82,7 @@ If no error shows up you are good to go. >>> import pyrogram >>> pyrogram.__version__ - '0.9.2' + '0.9.3' .. _TgCrypto: https://docs.pyrogram.ml/resources/TgCrypto .. _develop: http://github.com/pyrogram/pyrogram diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index debcc3f3..57ac6f08 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -31,7 +31,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès 50: self.channels_pts[channel_id] = self.channels_pts[channel_id][25:] - self.dispatcher.updates.put_nowait((update, updates.users, updates.chats)) + self.dispatcher.updates_queue.put_nowait((update, updates.users, updates.chats)) elif isinstance(updates, (types.UpdateShortMessage, types.UpdateShortChatMessage)): diff = await self.send( functions.updates.GetDifference( @@ -861,7 +861,7 @@ class Client(Methods, BaseClient): ) if diff.new_messages: - self.dispatcher.updates.put_nowait(( + self.dispatcher.updates_queue.put_nowait(( types.UpdateNewMessage( message=diff.new_messages[0], pts=updates.pts, @@ -871,9 +871,9 @@ class Client(Methods, BaseClient): diff.chats )) else: - self.dispatcher.updates.put_nowait((diff.other_updates[0], [], [])) + self.dispatcher.updates_queue.put_nowait((diff.other_updates[0], [], [])) elif isinstance(updates, types.UpdateShort): - self.dispatcher.updates.put_nowait((updates.update, [], [])) + self.dispatcher.updates_queue.put_nowait((updates.update, [], [])) elif isinstance(updates, types.UpdatesTooLong): log.warning(updates) except Exception as e: diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/dispatcher/dispatcher.py index 74ea37fd..99702b5c 100644 --- a/pyrogram/client/dispatcher/dispatcher.py +++ b/pyrogram/client/dispatcher/dispatcher.py @@ -50,14 +50,12 @@ class Dispatcher: MESSAGE_UPDATES = NEW_MESSAGE_UPDATES + EDIT_MESSAGE_UPDATES - UPDATES = None - def __init__(self, client, workers: int): self.client = client self.workers = workers self.update_worker_tasks = [] - self.updates = asyncio.Queue() + self.updates_queue = asyncio.Queue() self.groups = OrderedDict() async def message_parser(update, users, chats): @@ -72,14 +70,14 @@ class Dispatcher: async def user_status_parser(update, users, chats): return utils.parse_user_status(update.status, update.user_id), UserStatusHandler - Dispatcher.UPDATES = { + self.update_parsers = { Dispatcher.MESSAGE_UPDATES: message_parser, Dispatcher.DELETE_MESSAGE_UPDATES: deleted_messages_parser, Dispatcher.CALLBACK_QUERY_UPDATES: callback_query_parser, (types.UpdateUserStatus,): user_status_parser } - Dispatcher.UPDATES = {key: value for key_tuple, value in Dispatcher.UPDATES.items() for key in key_tuple} + self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple} async def start(self): for i in range(self.workers): @@ -91,7 +89,7 @@ class Dispatcher: async def stop(self): for i in range(self.workers): - self.updates.put_nowait(None) + self.updates_queue.put_nowait(None) for i in self.update_worker_tasks: await i @@ -115,7 +113,7 @@ class Dispatcher: async def update_worker(self): while True: - update = await self.updates.get() + update = await self.updates_queue.get() if update is None: break @@ -125,7 +123,7 @@ class Dispatcher: chats = {i.id: i for i in update[2]} update = update[0] - parser = Dispatcher.UPDATES.get(type(update), None) + parser = self.update_parsers.get(type(update), None) if parser is None: continue