Skip to content

Commit

Permalink
Fixes #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 fdbc1e0 commit 2ebe1f0
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:

Check warning on line 29 in src/tribler/core/utilities/slow_coro_detection/utils.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/tribler/core/utilities/slow_coro_detection/utils.py#L29

Catching too general exception Exception
stack = f'Stack is unavailable: {e.__class__.__name__}: {e}'

Check warning on line 30 in src/tribler/core/utilities/slow_coro_detection/utils.py

View check run for this annotation

Codecov / codecov/patch

src/tribler/core/utilities/slow_coro_detection/utils.py#L29-L30

Added lines #L29 - L30 were not covered by tests
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 2ebe1f0

Please sign in to comment.