Replacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode.
(f=None, limit=None)
| 68 | |
| 69 | |
| 70 | def extract_stack(f=None, limit=None): |
| 71 | """Replacement for traceback.extract_stack() that only does the |
| 72 | necessary work for asyncio debug mode. |
| 73 | """ |
| 74 | if f is None: |
| 75 | f = sys._getframe().f_back |
| 76 | if limit is None: |
| 77 | # Limit the amount of work to a reasonable amount, as extract_stack() |
| 78 | # can be called for each coroutine and future in debug mode. |
| 79 | limit = constants.DEBUG_STACK_DEPTH |
| 80 | stack = traceback.StackSummary.extract(traceback.walk_stack(f), |
| 81 | limit=limit, |
| 82 | lookup_lines=False) |
| 83 | stack.reverse() |
| 84 | return stack |