- Notifications
You must be signed in to change notification settings - Fork5.7k
Is there a way to run a concurrent async function while the bot mains?#4715
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I have created a bot, and I need an extern service to run concurrently to the bot. importasyncioasyncdefmain():bot=TheTelegramBotIHaveCreated(TOKEN)asyncio.create_task(run_concurrent_service())bot.application().run_polling()asyncio.run(main()) I get this error: Traceback (mostrecentcalllast):File"/home/kaki/.local/lib/python3.10/site-packages/telegram/ext/_application.py",line1112,in__runloop.run_until_complete(self.shutdown())File"/usr/lib/python3.10/asyncio/base_events.py",line625,inrun_until_completeself._check_running()File"/usr/lib/python3.10/asyncio/base_events.py",line584,in_check_runningraiseRuntimeError('This event loop is already running')RuntimeError:Thiseventloopisalreadyrunning How can I launch a bot without creating a new event loop? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment
-
Hi. Please have a look athttps://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-requested-design-patterns#running-ptb-alongside-other-asyncio-frameworks |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
0 replies
Answer selected byKaki-In
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment