I have a gevent application that spawns multiple greenlets across multiple modules. I want to be able to gracefully shutdown the application (either internally or by catching
According to another SO answer, it's possible "to iterate through all the objects on the heap and search for greenlets." So, I imagine this ought to work:
import gc
import gevent
from greenlet import greenlet
gevent.killall([obj for obj in gc.get_objects() if isinstance(obj, greenlet)])