Skip to content

Conversation

@magexiao6
Copy link

No description provided.

Refactor update_settings to handle dynamic field changes and determine if a restart is needed based on new settings.
"Restart requested due to changes in: %s",
", ".join(sorted(restart_fields & changed_fields)),
)
self._restart_event.set() # Signal restart
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what you are trying to do here is just make sure we only update the connection if the relevant settings change?

Could it be simplified like this:

restart_needed = (
    self.settings is None or \
    any([
        getattr(self.settings, k) != getattr(new_settings, k)
        for k in restart_fields
    ])
)

self.settings = new_settings
if restart_needed:
    self._restart_event.set()

self.settings = new_settings
else:
for key, value in new_values.items():
setattr(self.settings, key, value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just overwrite the settings object if you are going to overwrite all of it's values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants