Matt Matt - 17 days ago 5
Python Question

Python asyncio monitoring

I've a python program which are launching a random number of asyncio coroutine. During the time my program can launch new ones and some of them can exit when they have terminated their work.

I would like to know if it's possible to report, every minute, the number of active coroutine?

Thanks

Answer

You cannot launch a coroutine but could start a new task

For retrieving the number of active tasks please use len(asyncio.Task.all_tasks()).

Comments