Replacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode.
(limit=10)
| 2778 | |
| 2779 | |
| 2780 | def _extract_stack(limit=10): |
| 2781 | """Replacement for traceback.extract_stack() that only does the |
| 2782 | necessary work for asyncio debug mode. |
| 2783 | """ |
| 2784 | frame = sys._getframe().f_back |
| 2785 | try: |
| 2786 | stack = traceback.StackSummary.extract( |
| 2787 | traceback.walk_stack(frame), lookup_lines=False) |
| 2788 | finally: |
| 2789 | del frame |
| 2790 | |
| 2791 | apg_path = asyncpg.__path__[0] |
| 2792 | i = 0 |
| 2793 | while i < len(stack) and stack[i][0].startswith(apg_path): |
| 2794 | i += 1 |
| 2795 | stack = stack[i:i + limit] |
| 2796 | |
| 2797 | stack.reverse() |
| 2798 | return ''.join(traceback.format_list(stack)) |
| 2799 | |
| 2800 | |
| 2801 | def _check_record_class(record_class): |