While trying to find a solution for a program deadlocking in eventlet, I am wondering whether tulip programs might not face the same issue. If you have a bunch of tulip coroutines all waiting on some network event that is never going to arrive, would it be possible to just print a stack trace for each of them?
In eventlet, you can enable stack traces with eventlet.debug.hub_listener_stacks(True), and then print the stack traces whenever you want with eventlet.debug.format_hub_listeners(). Unfortunately, enabling the stack traces incurs a performance penalty and cannot be enabled in production code.
I did not find anything similar in gevent.
In tulip, coroutines are powered by generator functions. I wonder if we can print the stack trace of all waiting coroutines handled by tulip? Ideally, it should be a method in the event loop class.
A quick research shows that generator objects have gi_code and gi_frame attributes, that should at least allow printing the file name and line number of each coroutine known to Tulip. The full stack trace would be better, but it is probably too expensive to keep track of.
So I would propose a method like:
BaseEventLoop.format_running_coroutines()
It would return a multiline string showing the state of running coroutines, based on gi_frame and gi_code, possibly some more info.
Comments?
--
Gustavo J. A. M. Carneiro
Gambit Research LLC
"The universe is always one step beyond logic." -- Frank Herbert