telepot
telepot copied to clipboard
Trying to dive into telepot.aio and failing miserably
Hello,
I have tried to go away from my telepot threading designed applications to async. Sadly, I am not able to handle multiple tasks/coroutines together with a MessageLoop. My main approach was:
def run():
loop = asyncio.get_event_loop()
tasks = [self.__process(loop),
MessageLoop(self.__client,
{
'default': self.__on_something,
'callback_query': self.__on_callback_querry
}).run_forever()]
asyncio.gather(*tasks)
loop.run_forever()
async def __process():
...
Besides that I tried a lot more but couldn't figure it out. I nailed it down that my biggest issue to handle is the MessageLoop.run_forever()
blocking any other same loop coroutines.
Sadly I couldn't find an async example with UpdatesLoop AND MessageLoop or a combination with other coroutines. Could you lead me to a solution which makes the above code work?
OK. Maybe you should try to follow some of the examples first. Those files ending with *a.py
are async version. Start from the simple ones. Try to get the hang of it from there. Good luck.