I get this error:
\nTraceback (most recent call last):\n File \"/home/kaki/.local/lib/python3.10/site-packages/telegram/ext/_application.py\", line 1112, in __run\n loop.run_until_complete(self.shutdown())\n File \"/usr/lib/python3.10/asyncio/base_events.py\", line 625, in run_until_complete\n self._check_running()\n File \"/usr/lib/python3.10/asyncio/base_events.py\", line 584, in _check_running\n raise RuntimeError('This event loop is already running')\nRuntimeError: This event loop is already runningHow can I launch a bot without creating a new event loop?
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Hi. Please have a look at https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-requested-design-patterns#running-ptb-alongside-other-asyncio-frameworks
","upvoteCount":2,"url":"https://github.com/python-telegram-bot/python-telegram-bot/discussions/4715#discussioncomment-12454109"}}}-
|
I have created a bot, and I need an extern service to run concurrently to the bot. import asyncio
async def main():
bot = TheTelegramBotIHaveCreated(TOKEN)
asyncio.create_task(run_concurrent_service())
bot.application().run_polling()
asyncio.run(main())I get this error: Traceback (most recent call last):
File "/home/kaki/.local/lib/python3.10/site-packages/telegram/ext/_application.py", line 1112, in __run
loop.run_until_complete(self.shutdown())
File "/usr/lib/python3.10/asyncio/base_events.py", line 625, in run_until_complete
self._check_running()
File "/usr/lib/python3.10/asyncio/base_events.py", line 584, in _check_running
raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already runningHow can I launch a bot without creating a new event loop? |
Beta Was this translation helpful? Give feedback.
-
|
Hi. Please have a look at https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-requested-design-patterns#running-ptb-alongside-other-asyncio-frameworks |
Beta Was this translation helpful? Give feedback.
Hi. Please have a look at https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-requested-design-patterns#running-ptb-alongside-other-asyncio-frameworks