Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove surplus logging from updater network loop#4432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

MartinHjelmare
Copy link
Contributor

@MartinHjelmareMartinHjelmare commentedAug 18, 2024
edited
Loading

Background

When there's aTelegramError in theUpdater._network_loop_retry method, the exception is currently both logged and passed to theon_err_cb.

Example log:

2024-08-18 03:11:51.704 ERROR (MainThread) [telegram.ext.Updater] Error while getting Updates: Bad Gateway2024-08-18 03:11:51.704 ERROR (MainThread) [telegram.ext.Updater] Exception happened while polling for updates.Traceback (most recent call last):  File "/usr/local/lib/python3.12/site-packages/telegram/ext/_updater.py", line 742, in _network_loop_retry    if not await do_action():^^^^^^^^^^^^^^^^^  File "/usr/local/lib/python3.12/site-packages/telegram/ext/_updater.py", line 736, in do_action    return action_cb_task.result()^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/local/lib/python3.12/site-packages/telegram/ext/_updater.py", line 387, in polling_action_cb    raise exc  File "/usr/local/lib/python3.12/site-packages/telegram/ext/_updater.py", line 376, in polling_action_cb    updates = await self.bot.get_updates(^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/local/lib/python3.12/site-packages/telegram/_bot.py", line 541, in decorator    result = await func(self,*args,**kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/local/lib/python3.12/site-packages/telegram/_bot.py", line 4177, in get_updates    await self._post(  File "/usr/local/lib/python3.12/site-packages/telegram/_bot.py", line 629, in _post    return await self._do_post(^^^^^^^^^^^^^^^^^^^^  File "/usr/local/lib/python3.12/site-packages/telegram/_bot.py", line 657, in _do_post    return await request.post(^^^^^^^^^^^^^^^^^^^  File "/usr/local/lib/python3.12/site-packages/telegram/request/_baserequest.py", line 200, in post    result = await self._request_wrapper(^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/local/lib/python3.12/site-packages/telegram/request/_baserequest.py", line 383, in _request_wrapper    raise NetworkError(description or "Bad Gateway")telegram.error.NetworkError: Bad Gateway

Proposed changes

  • I'd like to remove the direct logging of the exception (first log line above), since the error callback also handles the exception. The user of the library is then free to handle the exception as wished, potentially without logging. The default error callback will still log the exception (second log line above) if the user doesn't customizes the error callback.

@MartinHjelmare
Copy link
ContributorAuthor

MartinHjelmare commentedAug 18, 2024
edited
Loading

Remaining CI test failures seem unrelated to the PR change.

Copy link
Member

@Bibo-JoshiBibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice finding, thanks for seding a PR!

MartinHjelmare reacted with thumbs up emojiomidbarzegaran85 reacted with rocket emoji
@Bibo-JoshiBibo-Joshi merged commita05362c intopython-telegram-bot:masterAug 19, 2024
24 of 25 checks passed
@MartinHjelmareMartinHjelmare deleted the updater-logging-cleanup branchAugust 19, 2024 17:01
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 27, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@Bibo-JoshiBibo-JoshiBibo-Joshi approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@MartinHjelmare@Bibo-Joshi

[8]ページ先頭

©2009-2025 Movatter.jp