Skip to content

Tag: python-asyncio

Running a loop while using telethon

I’m making a telegram channel admin control script that needs checking channel in a loop. I also want some message handlers checking for messages. Here is a part of my code: If i use client.loop.run_until_complete(main()), message handler won’t work but main runs prefectly. and if I use client.run…

How to collect wait()’d co-routines in a set?

I have been attempting to generate a ping scan that uses a limited number of processes. I tried as_completed without success and switched to asyncio.wait with asyncio.FIRST_COMPLETED. The following complete script works if the offending line is commented out. I’d like to collect the tasks to a set in or…

Python asyncio cancel unawaited coroutines

So given a bit of a complex setup, which is used to generate a list of queries to be run semi-parallel (using a semaphore to not run too many queries at the same time, to not DDoS the server). i have an (in itself async) function that creates a number of queries: Now this works very nicely, executing exactly …