• Jason Madden's avatar
    Add a GreenletTree for more organized, clearer output of greenlets · 5d4bdad6
    Jason Madden authored
    It organizes things by the spawning greenlet, if possible.
    
    Example output::
    
    ```
    <greenlet.greenlet object at 0x10753a9b0>
     :    Running:
     :      File "/tmp/t.py", line 38, in <module>
     :        print("\n".join(format_run_info()))
     :      File "//src/gevent/util.py", line 99, in format_run_info
     :        _format_greenlet_info(lines)
     :      File "//src/gevent/util.py", line 132, in _format_greenlet_info
     :        lines.extend(tree.format_lines(details=True))
     :      File "//src/gevent/util.py", line 265, in format_lines
     :        for l in self._render(tree)]
     :      File "/-main/src/gevent/util.py", line 310, in _render
     :        self.__render_tb(tree, 'Running:', self.greenlet.gr_frame)
     :      File "//src/gevent/util.py", line 281, in __render_tb
     :        tb = ''.join(traceback.format_stack(frame))
     :    Greenlet Locals:
     :      Local <type 'gevent._local.local'> at 0x10759cec0
     :        {'foo': 42}
     +--- <Greenlet "Greenlet-0" at 0x107405cb0: _run>; finished with value <Greenlet "Greenlet-4" at 0x10
     :          Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
     :          Spawned at:
     :            File "/tmp/t.py", line 1, in <module>
     :              from gevent.util import GreenletTree
     |    +--- <Greenlet "Greenlet-4" at 0x10780b260: _run>; finished
     :                Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
     :                Spawned at:
     :                  File "/tmp/t.py", line 1, in <module>
     :                    from gevent.util import GreenletTree
     :                  File "/tmp/t.py", line 12, in t2
     :                    def t2():
     +--- <Hub at 0x10753a550 select default pending=0 ref=0>
     :          Parent: <greenlet.greenlet object at 0x10753a9b0>
     :          Running:
     :            File "/Users/jmadden/Projects/GithubSources/gevent-main/src/gevent/hub.py", line 673, in run
     :              loop.run()
     +--- <Greenlet "Greenlet-1" at 0x10780b368: _run>; finished with value <Greenlet "Greenlet-5" at 0x10
     :          Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
     :          Spawned at:
     :            File "/tmp/t.py", line 1, in <module>
     :              from gevent.util import GreenletTree
     |    +--- <Greenlet "Greenlet-5" at 0x10780b578: _run>; finished
     :                Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
     :                Spawned at:
     :                  File "/tmp/t.py", line 1, in <module>
     :                    from gevent.util import GreenletTree
     :                  File "/tmp/t.py", line 12, in t2
     :                    def t2():
     +--- <Greenlet "Greenlet-2" at 0x10780b470: _run>; finished with value <Greenlet "Greenlet-6" at 0x10
     :          Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
     :          Spawned at:
     :            File "/tmp/t.py", line 1, in <module>
     :              from gevent.util import GreenletTree
     :          Spawn Tree Locals
     :          {'stl': 'STL'}
     |    +--- <Greenlet "Greenlet-6" at 0x10780b680: _run>; finished with value <Greenlet "Greenlet-7" at 0x10
     :                Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
     :                Spawned at:
     :                  File "/tmp/t.py", line 1, in <module>
     :                    from gevent.util import GreenletTree
     :                  File "/tmp/t.py", line 21, in t3
     :                    def t3():
     |         +--- <Greenlet "Greenlet-7" at 0x10780b788: _run>; finished
     :                      Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
     :                      Spawned at:
     :                        File "/tmp/t.py", line 1, in <module>
     :                          from gevent.util import GreenletTree
     :                        File "/tmp/t.py", line 21, in t3
     :                          def t3():
     :                        File "/tmp/t.py", line 12, in t2
     :                          def t2():
     +--- <Greenlet "Greenlet-3" at 0x10780b890: _run>; finished with value [<gevent.util.GreenletTree obj
                Parent: <Hub at 0x10753a550 select default pending=0 ref=0>
                Spawned at:
                  File "/tmp/t.py", line 1, in <module>
                    from gevent.util import GreenletTree
    ```
    5d4bdad6
To find the state of this project's repository at the time of any of these versions, check out the tags.
CHANGES.rst 123 KB