For debugging purposes, I would like to iterate over all greenlets and obtain their trace traces -- how can I do that with gevent?
Basically, I would like to do the gevent equivalent of this.
You can use the gc
module to iterate through all the objects on the heap and search for greenlets. Greenlets store the stack traces as an attribute gr_frame
.
import gc
import traceback
from greenlet import greenlet
for ob in gc.get_objects():
if not isinstance(ob, greenlet):
continue
if not ob:
continue
log.error(''.join(traceback.format_stack(ob.gr_frame)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With