When I use asyncio.gather
to run two asynchronous functions, one of which is infinite, the program does not stop with Ctrl + C.
One of them is idle related to pyrogram and the other is an endless function.
I tried many methods, but none of them worked.
The code:
from pyrogram.methods.utilities.idle import idle
from pyrogram.client import Client
from asyncio import sleep, run, gather
bot = Client(...)
async def time_checker():
while True:
print("I am still here !")
# await ...
await sleep(10)
async def main():
await bot.start()
await gather(idle(), time_checker())
await bot.stop()
run(main())
I tried try-except, signal.SIGINT, bot.is_connected and ...
I want both functions to run forever, but when Ctrl + C is used, the process will stop