Skip to content

Commit

Permalink
Comment is added to Component.start when handling DatabaseIsCorrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Nov 23, 2023
1 parent e31526d commit 386aba5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/tribler/core/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ async def start(self):
if isinstance(e, DatabaseIsCorrupted):
# When the database corruption is detected, we should stop the process immediately.
# Tribler GUI will restart the process and the database will be recreated.

# Usually we wrap an exception into ComponentStartupException, and allow
# CoreExceptionHandler.unhandled_error_observer to handle it after all components are started,
# but in this case we don't do it. The reason is that handling ComponentStartupException
# starts the shutting down of Tribler, and due to some obscure reasons it is not possible to
# raise any exception, even SystemExit, from CoreExceptionHandler.unhandled_error_observer when
# Tribler is shutting down. It looks like in this case unhandled_error_observer is called from
# Task.__del__ method and all exceptions that are raised from __del__ are ignored.
# See https://bugs.python.org/issue25489 for similar case.
process_manager = get_global_process_manager()
process_manager.sys_exit(EXITCODE_DATABASE_IS_CORRUPTED, e)
return # Added for clarity; actually, the code raised SystemExit on the previous line
Expand Down

0 comments on commit 386aba5

Please sign in to comment.