I'm running an asyncio application which needs more than one event loop to service a large number of IO operations (upward of a thousand simultaneously). The event loops run in a separate thread and loops forever on coroutines as they are submitted.
I'm looking for a way to identify when an existing event loop is near full capacity so I can fire up a new event loop thread on demand, rather than pre-specifying how many event loops I want to run.
Near capacity would mean the event loop is keeping busy say 80%+ of the time. If an event loop is spending less than 20% of its time in a wait state it's time to add another event loop thread.
It doesn't seem like this is easy per-thread: Profile Python CPU Usage By Thread