Skip to content

Commit

Permalink
Proper shutdown in case Tribler GUI cannot connect to Core
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Aug 17, 2022
1 parent 4b156d2 commit 799c5bb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/tribler/gui/core_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def on_core_connected(self, _):
self._logger.warning('Core connected after the core process is already finished')
return

if self.shutting_down:
self._logger.warning('Core connected after the shutting down is already started')
return

self.core_connected = True

def start(self, core_args=None, core_env=None, upgrade_manager=None, run_core=True):
Expand Down Expand Up @@ -151,8 +155,13 @@ def stop(self, quit_app_on_core_finished=True):
self.shutting_down = True
self._logger.info("Stopping Core manager")

need_to_shutdown_core = (self.core_process or self.core_connected) and not self.core_finished
if need_to_shutdown_core:
if self.core_process and not self.core_finished:
if not self.core_connected:
# If Core is not connected via events_manager it also most probably cannot process API requests.
self._logger.warning('Core is not connected during the CoreManager shutdown, killing it...')
self.kill_core_process_and_remove_the_lock_file()
return

self.events_manager.shutting_down = True

def shutdown_request_processed(response):
Expand All @@ -170,7 +179,7 @@ def send_shutdown_request(initial=False):
send_shutdown_request(initial=True)

elif self.should_quit_app_on_core_finished:
self._logger.info('Core finished, quitting GUI application')
self._logger.info('Core is not running, quitting GUI application')
self.app_manager.quit_application()

def kill_core_process_and_remove_the_lock_file(self):
Expand Down

0 comments on commit 799c5bb

Please sign in to comment.