Python
RuntimeWarning: coroutine 'Bot.send_message' was never awaited
ndlessrain
2023. 11. 22. 16:45
728x90
import asyncio
def send_telegram(msg):
new_str = []
new_str.append(msg)
new_str = ''.join(new_str)
asyncio.run(bot.sendMessage(chat_id, new_str))
텔레그램 봇 라이브러리가 업데이트되면서 async로 호출해야하는데,
나는 while loop 안에서 호출하는 거라 RuntimeError: asyncio.run() cannot be called from a running event loop 에러가 났는데....
import nest_asyncio
nest_asyncio.apply()
위 두 줄 추가하면 해결.
728x90