Title: [BUG] Bot hangs when using ctrl + c and MessageQueue · Issue #2012 · python-telegram-bot/python-telegram-bot · GitHub
Open Graph Title: [BUG] Bot hangs when using ctrl + c and MessageQueue · Issue #2012 · python-telegram-bot/python-telegram-bot
X Title: [BUG] Bot hangs when using ctrl + c and MessageQueue · Issue #2012 · python-telegram-bot/python-telegram-bot
Description: Steps to reproduce Set the working variable to False Run the bot using ./main.py Hit ctrl + c Expected behaviour The bot should stop. Actual behaviour The bot hangs. Configuration Operating System: 10.15.5 (19F101) Version of Python, pyt...
Open Graph Description: Steps to reproduce Set the working variable to False Run the bot using ./main.py Hit ctrl + c Expected behaviour The bot should stop. Actual behaviour The bot hangs. Configuration Operating System:...
X Description: Steps to reproduce Set the working variable to False Run the bot using ./main.py Hit ctrl + c Expected behaviour The bot should stop. Actual behaviour The bot hangs. Configuration Operating System:...
Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/issues/2012
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] Bot hangs when using ctrl + c and MessageQueue","articleBody":"\u003c!--\r\nThanks for reporting issues of python-telegram-bot!\r\n\r\nUse this template to notify us if you found a bug.\r\n\r\nTo make it easier for us to help you please enter detailed information below.\r\n\r\nPlease note, we only support the latest version of python-telegram-bot and\r\nmaster branch. Please make sure to upgrade & recreate the issue on the latest\r\nversion prior to opening an issue.\r\n-->\r\n### Steps to reproduce\r\n\r\n1. Set the `working` variable to `False`\r\n2. Run the bot using `./main.py`\r\n3. Hit \u003ckbd>ctrl\u003c/kbd> + \u003ckbd>c\u003c/kbd>\r\n\r\n### Expected behaviour\r\n\r\nThe bot should stop.\r\n\r\n### Actual behaviour\r\n\r\nThe bot hangs.\r\n\r\n### Configuration\r\n\r\n**Operating System:** 10.15.5 (19F101)\r\n\r\n**Version of Python, python-telegram-bot & dependencies:**\r\n\r\n```\r\npython-telegram-bot 12.8\r\ncertifi 2020.06.20\r\nPython 3.7.7 (default, Mar 10 2020, 15:43:33) [Clang 11.0.0 (clang-1100.0.33.17)]\r\n```\r\n\r\n### Logs\r\n\r\nWorking:\r\n\r\n```\r\n> ./main.py\r\n2020-07-02 12:59:25,880 - __main__ - INFO - Started polling\r\n2020-07-02 12:59:26,157 - __main__ - INFO - Bot started. Press Ctrl-C to stop.\r\n^C2020-07-02 12:59:27,504 - telegram.ext.updater - INFO - Received signal 2 (SIGINT), stopping...\r\n```\r\n\r\nthen exits.\r\n\r\nNot working:\r\n\r\n```\r\n> ./main.py\r\n2020-07-02 12:59:34,283 - telegram.ext.updater - WARNING - Connection pool of Request object is smaller than optimal value (8)\r\n2020-07-02 12:59:34,283 - __main__ - INFO - Started polling\r\n2020-07-02 12:59:34,537 - __main__ - INFO - Bot started. Press Ctrl-C to stop.\r\n^C2020-07-02 12:59:37,574 - telegram.ext.updater - INFO - Received signal 2 (SIGINT), stopping...\r\n```\r\n\r\nand hangs.\r\n\r\n`main.py`:\r\n\r\n```py\r\n#!/usr/bin/env python3\r\n# -*- coding: utf-8 -*-\r\n\r\nimport logging\r\n\r\nlogging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)\r\n\r\nfrom telegram.ext import Updater\r\n\r\nfrom queue_bot import QueueBot\r\n\r\nlogger = logging.getLogger(__name__)\r\nupdater = None\r\n\r\n\r\ndef main():\r\n logger.info('Started polling')\r\n\r\n updater.start_polling(timeout=0.01)\r\n\r\n logger.info('Bot started. Press Ctrl-C to stop.')\r\n\r\n updater.idle()\r\n\r\n\r\nif __name__ == '__main__':\r\n token = 'TOKEN'\r\n working = True\r\n\r\n if working:\r\n updater = Updater(token, use_context=True)\r\n else:\r\n queue_bot = QueueBot(token)\r\n updater = Updater(bot=queue_bot, use_context=True)\r\n\r\n main()\r\n```\r\n\r\n`queue_bot.py`:\r\n\r\n```py\r\n#!/usr/bin/env python3\r\n# -*- coding: utf-8 -*-\r\n\r\nfrom telegram.bot import Bot\r\nfrom telegram.ext import messagequeue\r\n\r\n\r\nclass QueueBot(Bot):\r\n def __init__(self, *args, **kwargs):\r\n super(QueueBot, self).__init__(*args, **kwargs)\r\n\r\n self._is_messages_queued_default = True\r\n self._msg_queue = messagequeue.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 @messagequeue.queuedmessage\r\n def send_message(self, *args, **kwargs):\r\n return super(QueueBot, self).send_message(*args, **kwargs)\r\n```","author":{"url":"https://github.com/revolter","@type":"Person","name":"revolter"},"datePublished":"2020-07-02T10:02:50Z","url":"https://github.com/python-telegram-bot/python-telegram-bot/issues/2012"}
| 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:60c1ce75-ab23-04aa-7710-57cc439ce4c9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C646:1F95:73F51B:96C048:6B025CEB |
| html-safe-nonce | 1d4c8c20b1456a12437136bcf6e6276120f736121c5e976719fb1b8b60f9b94e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjQ2OjFGOTU6NzNGNTFCOjk2QzA0ODo2QjAyNUNFQiIsInZpc2l0b3JfaWQiOiI1ODI1NjIzNTg2ODc4MTUxOTE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 301d955036b61ec25b108eee1416515d86ab86148ec482abfe40c041240195dc |
| hovercard-subject-tag | issue:649804244 |
| 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/2012/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ee867b3847a49e1d398c129ca8fbda6c0db1a53823a2fdda56dd15ccaf745d27/python-telegram-bot/python-telegram-bot/issues/2012 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ee867b3847a49e1d398c129ca8fbda6c0db1a53823a2fdda56dd15ccaf745d27/python-telegram-bot/python-telegram-bot/issues/2012 |
| og:image:alt | Steps to reproduce Set the working variable to False Run the bot using ./main.py Hit ctrl + c Expected behaviour The bot should stop. Actual behaviour The bot hangs. Configuration Operating System:... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | revolter |
| 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