-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass the number of the opened REST API port from Core to GUI #7251
Conversation
@@ -176,7 +223,7 @@ def stop(self, quit_app_on_core_finished=True): | |||
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() | |||
self.kill_core_process() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This renaming should actually be in the previous PR... When I extracted the current PR from the previous one, I missed this line...
@@ -65,6 +65,16 @@ def __init__(self, api_port, api_key, error_handler): | |||
notifier.add_observer(notifications.tribler_shutdown_state, self.on_tribler_shutdown_state) | |||
notifier.add_observer(notifications.report_config_error, self.on_report_config_error) | |||
|
|||
def create_request(self) -> QNetworkRequest: | |||
url = QUrl("http://localhost:%d/events" % self.api_port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT
url = QUrl("http://localhost:%d/events" % self.api_port) | |
url = QUrl(f'http://localhost:{self.api_port}/events') |
src/tribler/gui/core_manager.py
Outdated
Determines the actual REST API port of the Core process. | ||
|
||
This function is first executed from the `on_core_started` after the physical Core process starts and then | ||
repeatedly executed after API_PORT_CHECK_INTERVAL seconds until it retrieves the REST API port value from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"after API_PORT_CHECK_INTERVAL
seconds" --> to avoid any confusion, this is in milliseconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, thanks!
This PR is based on @xoriole's PR #7162 and fixes #7137. What is different is the way how GUI determines the opened API port. In the current PR, GUI takes the
api_port
value from the processes database.Previously, EventRequestManager initially attempted to connect to the already running independently launched Core. Then in case a new Core process is started, EventRequestManager immediately starts repeated attempts to connect to it.
Now, EventRequestManager connects to the launched Core only after the Core REST API manager is started. Before that, CoreManager periodically attempts to read the
api_port
value from the processes database.In case of a crash, the API port values (an initial value suggested by GUI and an actual value used by Core) are available in the error report as part of process information (in the
last_processes
section).