Is there a way to tell if an asyncio event loop is at full capacity?
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
I don't think this approach can work because of the GIL. The use case you seem to be describing is that of event loops stalling due to CPU overload. If that is the case, adding more threads won't help simply because CPU work is, except for rare exceptions, not parallelized in Python.
If your event loops are doing too much CPU-related work (e.g. calculations), you should move those individual units of work to separate threads using run_in_executor
. If that is not enough, you can try switching to uvloop, a high-performance asyncio drop-in replacement for CPython. You can also try asyncio with PyPy.
If none of those options work, the next thing to try is some variant of multiprocessing. (Or a more low-level/performance-oriented language.)