Skip to content

Commit

Permalink
Fixes Tribler#7600: handle exceptions in task.print_stack()
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Oct 2, 2023
1 parent e547c08 commit 26bf1bc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tribler/core/utilities/slow_coro_detection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ def format_info(handle: Handle, include_stack: bool = False, stack_cut_duration:

if not main_stack_tracking_is_enabled():
stream = io.StringIO()
task.print_stack(limit=limit, file=stream)
stack = stream.getvalue()
try:
task.print_stack(limit=limit, file=stream)
except Exception as e: # pylint: disable=broad-except
stack = f'Stack is unavailable: {e.__class__.__name__}: {e}'
else:
stack = stream.getvalue()
else:
stack = get_main_thread_stack(stack_cut_duration, limit, enable_profiling_tip)
return f"{task}\n{stack}"

0 comments on commit 26bf1bc

Please sign in to comment.