gbulb icon indicating copy to clipboard operation
gbulb copied to clipboard

Assertion fails in ReadTransport when used in conjunction with python-telegram-bot

Open arbu opened this issue 1 year ago • 0 comments

Describe the bug

When using python-telegram-bot with gbulb installed, a stacktrace in gbulbs transport.py will be logged on some of the API calls. The bot continues to poll for updates. From my limited tests, all the messages seem to be successfully received as well. So for my case this is not really an error. But if the incoming connection is not fully consumed, this might have an impact on other applications though.

Steps to reproduce

Get a telegram bot token and run the following minimal telegram bot with the TELEGRAM_TOKEN env set to the token:

import gbulb

gbulb.install()

import os
import logging
import signal
from telegram.ext import ApplicationBuilder

logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.DEBUG
)

if __name__ == "__main__":
    application = ApplicationBuilder().token(os.environ.get("TELEGRAM_TOKEN")).build()

    application.run_polling(stop_signals=(signal.SIGINT, signal.SIGTERM))

An AssertionError in ReadTransport._loop_reading will be logged

Expected behavior

No error message

Screenshots

No response

Environment

  • Operating System: Arch Linux
  • Python version: 3.10
  • Software versions (installed via pipenv):
    • gbulb 0.6.4
    • python-telegram-bot 20.2

Logs

2023-03-26 19:07:46,941 - telegram.ext._updater - DEBUG - Start network loop retry getting Updates
2023-03-26 19:07:46,941 - telegram._bot - DEBUG - Entering: get_updates
2023-03-26 19:07:46,942 - telegram.ext._application - INFO - Application started
2023-03-26 19:07:46,989 - asyncio - ERROR - Exception in callback ReadTransport._loop_reading(<Future finis...1cL9)\xcd\\P'>)
handle: <GLibHandle ReadTransport._loop_reading(<Future finis...1cL9)\xcd\\P'>)>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/aaron/.local/share/virtualenvs/gbulb-test-tg-bot-qwCEH6Yd/lib/python3.10/site-packages/gbulb/transports.py", line 141, in _loop_reading
    self._read_fut is None and self._closing
AssertionError

Additional context

No response

arbu avatar Mar 26 '23 17:03 arbu