← 返回首页
fix(dispatcher): mark tasks as done after taking elements off queue by d-Rickyy-b · Pull Request #1305 · pyrogram/pyrogram · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

fix(dispatcher): mark tasks as done after taking elements off queue#1305

Open
d-Rickyy-b wants to merge 1 commit into
pyrogram:masterfrom
d-Rickyy-b:master
Open

fix(dispatcher): mark tasks as done after taking elements off queue#1305
d-Rickyy-b wants to merge 1 commit into
pyrogram:masterfrom
d-Rickyy-b:master

Conversation

Copy link
Copy Markdown

This PR fixes an issue where the updates_queue.join() method would never return. When waiting for the updates_queue to get emptied, the asyncio queue implementation relies on an internal counter. This counter is incremented on each put() but is not automatically decremented on each get(). In order to decrement the counter we need to use updates_queue.task_done(), as per the docs. Since this wasn't done in pyrogram yet, there was no proper way to use the join() method on the updates_queue and hence wait until all updates got processed.

A workaround would be to use a while loop and check if updates_queue.empty() returns true. But using join() is just a lot cleaner and does not require a loop on our end.

…_queue This commit fixes an issue where the `updates_queue.join()` method would never return. When waiting for the `updates_queue` to get emptied, the asyncio queue implementation relies on an internal counter. This counter is incremented on each `put()` but is not automatically decremented on each `get()`. In order to decrement the counter we need to use `updates_queue.task_done()`, as per the [docs](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue.task_done). Since this wasn't done in pyrogram yet, there was no proper way to use the `join()` method on the updates_queue and hence wait until all updates got processed. A workaround would be to use a while loop and check if `updates_queue.empty()` returns true. But using `join()` is just a lot cleaner and does not require a loop on our end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Footer

© 2026 GitHub, Inc.