Title: [BUG] Promise ignores exceptions · Issue #3201 · python-telegram-bot/python-telegram-bot · GitHub
Open Graph Title: [BUG] Promise ignores exceptions · Issue #3201 · python-telegram-bot/python-telegram-bot
X Title: [BUG] Promise ignores exceptions · Issue #3201 · python-telegram-bot/python-telegram-bot
Description: Steps to Reproduce This bug has already been catched and fixed - #2542 But it still exists. Here is the code. Run it and send /bug command to the bot and you will see nothing in console, but I expect traceback to appear. #!/usr/bin/env p...
Open Graph Description: Steps to Reproduce This bug has already been catched and fixed - #2542 But it still exists. Here is the code. Run it and send /bug command to the bot and you will see nothing in console, but I expe...
X Description: Steps to Reproduce This bug has already been catched and fixed - #2542 But it still exists. Here is the code. Run it and send /bug command to the bot and you will see nothing in console, but I expe...
Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/issues/3201
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] Promise ignores exceptions","articleBody":"### Steps to Reproduce\n\nThis bug has already been catched and fixed - https://github.com/python-telegram-bot/python-telegram-bot/issues/2542\r\nBut it still exists.\r\n\r\nHere is the code. Run it and send `/bug` command to the bot and you will see nothing in console, but I expect traceback to appear.\r\n\r\n```\r\n#!/usr/bin/env python3\r\n# encoding=utf-8\r\n\r\n'''\r\nMessageQueue usage example with @queuedmessage decorator.\r\nProvide your bot token with `TOKEN` environment variable or list it in\r\nfile `token.txt`\r\n'''\r\n\r\nimport telegram.bot\r\nfrom telegram.ext import messagequeue as mq\r\n\r\n\r\nclass MQBot(telegram.bot.Bot):\r\n '''A subclass of Bot which delegates send method handling to MQ'''\r\n def __init__(self, *args, is_queued_def=True, mqueue=None, **kwargs):\r\n super(MQBot, self).__init__(*args, **kwargs)\r\n # below 2 attributes should be provided for decorator usage\r\n self._is_messages_queued_default = is_queued_def\r\n self._msg_queue = mqueue or mq.MessageQueue()\r\n\r\n def __del__(self):\r\n try:\r\n self._msg_queue.stop()\r\n except:\r\n pass\r\n\r\n @mq.queuedmessage\r\n def send_message(self, *args, **kwargs):\r\n '''Wrapped method would accept new `queued` and `isgroup`\r\n OPTIONAL arguments'''\r\n return super(MQBot, self).send_message(*args, **kwargs)\r\n\r\n\r\nif __name__ == '__main__':\r\n from telegram import ParseMode\r\n from telegram.ext import MessageHandler, Filters, CommandHandler\r\n from telegram.utils.request import Request\r\n import os\r\n token = os.environ.get('TOKEN') or open('token.txt').read().strip()\r\n # for test purposes limit global throughput to 3 messages per 3 seconds\r\n q = mq.MessageQueue(all_burst_limit=3, all_time_limit_ms=3000)\r\n # set connection pool size for bot \r\n request = Request(con_pool_size=8)\r\n testbot = MQBot(token, request=request, mqueue=q)\r\n upd = telegram.ext.updater.Updater(bot=testbot, use_context=True)\r\n\r\n\r\n def show_bug(update, context):\r\n \"\"\"\r\n The dot in \"Hello, World.\" should raise an exception\r\n because it is unescaped.\r\n \"\"\"\r\n context.bot.send_message(\r\n chat_id=update.effective_chat.id,\r\n text=\"Hello, World.\",\r\n parse_mode=ParseMode.MARKDOWN_V2\r\n )\r\n\r\n def start(update, context):\r\n context.bot.send_message(\r\n chat_id=update.effective_chat.id,\r\n text=r\"Hello, World\\.\",\r\n parse_mode=ParseMode.MARKDOWN_V2\r\n )\r\n\r\n upd.dispatcher.add_handler(CommandHandler(\"start\", start))\r\n\r\n upd.dispatcher.add_handler(CommandHandler(\"bug\", show_bug))\r\n upd.start_polling()\r\n```\n\n### Expected behaviour\n\nException is catched.\n\n### Actual behaviour\n\nException is eaten up by Promise and never show up.\n\n### Operating System\n\nWindows 10\n\n### Version of Python, python-telegram-bot & dependencies\n\n```shell\npython-telegram-bot 13.13\r\nBot API 6.1\r\ncertifi2021.10.08\r\nPython 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]\n```\n\n\n### Relevant log output\n\n_No response_\n\n### Additional Context\n\nI'm using Promises within MessageQueue. I know that it is deprecated, but I think that at least this issue is worth mentioning here https://github.com/python-telegram-bot/python-telegram-bot/issues/2139","author":{"url":"https://github.com/elebur","@type":"Person","name":"elebur"},"datePublished":"2022-08-20T22:24:18Z","url":"https://github.com/python-telegram-bot/python-telegram-bot/issues/3201"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b966d01d-f7f5-3b1f-9387-6dcd43da2b29 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E230:187983:9E0A4D:CEDC9F:6B025DCC |
| html-safe-nonce | a0f5baed2cd80bfd43418b99bea17e275ba5753906065a7f85ddcc1972a29d7a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjMwOjE4Nzk4Mzo5RTBBNEQ6Q0VEQzlGOjZCMDI1RENDIiwidmlzaXRvcl9pZCI6IjI1MzQ4OTYxNzI0MTAyMzIyNjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5343455250aea7ab2fc6dfbbef84c7687da638ae3a4a449ddfefc276aa7947d9 |
| hovercard-subject-tag | issue:1345312467 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-telegram-bot/python-telegram-bot/3201/issue_layout |
| twitter:image | https://opengraph.githubassets.com/135032f0e9fe1749056a5b730033ad468f85c3ffb9e1dacd99e6c837bfde1127/python-telegram-bot/python-telegram-bot/issues/3201 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/135032f0e9fe1749056a5b730033ad468f85c3ffb9e1dacd99e6c837bfde1127/python-telegram-bot/python-telegram-bot/issues/3201 |
| og:image:alt | Steps to Reproduce This bug has already been catched and fixed - #2542 But it still exists. Here is the code. Run it and send /bug command to the bot and you will see nothing in console, but I expe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | elebur |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-telegram-bot/python-telegram-bot git https://github.com/python-telegram-bot/python-telegram-bot.git |
| octolytics-dimension-user_id | 16178365 |
| octolytics-dimension-user_login | python-telegram-bot |
| octolytics-dimension-repository_id | 38696925 |
| octolytics-dimension-repository_nwo | python-telegram-bot/python-telegram-bot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38696925 |
| octolytics-dimension-repository_network_root_nwo | python-telegram-bot/python-telegram-bot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width