@classmethod
    def format_greenlet(cls, gl):
        """
        Returns a tuple of [status/self/func] and stack if applicable.
        """
        if gl.dead:
            return (["    (dead)"], [])
        else:
            selfstr = "(unknown)"
            funcstr = "(unknown)"
            if hasattr(gl, "_run"):
                boundstr = "unbound"
                if hasattr(gl._run, 'im_self'):
                    selfstr = str(gl._run.im_self)
                    boundstr = "bound"

                try:
                    if hasattr(gl._run, 'im_func'):
                        funcstr = "%s, %s.%s" % (boundstr, gl._run.im_class.__name__, gl._run.im_func.__name__)
                    elif hasattr(gl._run, 'func_name'):
                        funcstr = "%s, %s" % (boundstr, func_name)

                except Exception as ex:
                    #print "WHAT HAPPEN", ex
                    pass

            selfstr = "self: " + selfstr
            funcstr = "func: " + funcstr

            # greenlet traceback (maybe interesting)
            gltb = traceback.format_stack(gl.gr_frame)

            return ([selfstr, funcstr], gltb)
dataset/ETHPy150Open ooici/pyon/pyon/util/greenlet_plugin.py/GreenletLeak.format_greenlet/original