The library throws an error
\n File \"/usr/lib/python3.13/asyncio/selector_events.py\", line 101, in close\n raise RuntimeError(\"Cannot close a running event loop\")\nRuntimeError: Cannot close a running event loop\n<sys>:0: RuntimeWarning: coroutine 'Application.shutdown' was never awaited\n<sys>:0: RuntimeWarning: coroutine 'Application._bootstrap_initialize' was never awaited\nHow would I achieve the correct behavior?
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"","upvoteCount":1,"url":"https://github.com/python-telegram-bot/python-telegram-bot/discussions/4901#discussioncomment-14066005"}}}-
|
Consider the code below import asyncio
from os import environ
from telegram.ext import ApplicationBuilder
TELEGRAM_BOT_TOKEN = environ['TELEGRAM_BOT_TOKEN']
async def main():
await asyncio.sleep(1)
app = ApplicationBuilder().token(TELEGRAM_BOT_TOKEN).build()
app.run_polling()
if __name__ == '__main__':
asyncio.run(main())The library throws an error How would I achieve the correct behavior? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Found solution: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-requested-design-patterns#running-ptb-alongside-other-asyncio-frameworks