-
|
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 File "/usr/lib/python3.13/asyncio/selector_events.py", line 101, in close
raise RuntimeError("Cannot close a running event loop")
RuntimeError: Cannot close a running event loop
<sys>:0: RuntimeWarning: coroutine 'Application.shutdown' was never awaited
<sys>:0: RuntimeWarning: coroutine 'Application._bootstrap_initialize' was never awaited
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