From d02fa72e8013b31c17d8adc6d44f6cb259169f8e Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 27 Apr 2020 16:14:17 +0100 Subject: [Console] Fix hostlist status lookup errors If a host in hostlist failed DNS lookup or other issue it was returning a tuple instead of deferred. Fix this in hostlist by returning a defer.succeed. A race condition with BaseMode was also encountered when update_hosts_status calls update_select_host_popup and ConnectionManager does not have a rows attribute. Fix this by init BaseMode before update_hosts_status and remove already called update_select_host_popup. --- deluge/ui/console/modes/connectionmanager.py | 12 +++++------- deluge/ui/hostlist.py | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/deluge/ui/console/modes/connectionmanager.py b/deluge/ui/console/modes/connectionmanager.py index 84a3fbc14..a5c596860 100644 --- a/deluge/ui/console/modes/connectionmanager.py +++ b/deluge/ui/console/modes/connectionmanager.py @@ -32,9 +32,8 @@ class ConnectionManager(BaseMode, PopupsHandler): self.statuses = {} self.all_torrents = None self.hostlist = HostList() - self.update_hosts_status() BaseMode.__init__(self, stdscr, encoding=encoding) - self.update_select_host_popup() + self.update_hosts_status() def update_select_host_popup(self): selected_index = self.popup.current_selection() if self.popup else None @@ -71,12 +70,11 @@ class ConnectionManager(BaseMode, PopupsHandler): self.refresh() def update_hosts_status(self): - for host_entry in self.hostlist.get_hosts_info(): - - def on_host_status(status_info): - self.statuses[status_info[0]] = status_info - self.update_select_host_popup() + def on_host_status(status_info): + self.statuses[status_info[0]] = status_info + self.update_select_host_popup() + for host_entry in self.hostlist.get_hosts_info(): self.hostlist.get_host_status(host_entry[0]).addCallback(on_host_status) def _on_connected(self, result): diff --git a/deluge/ui/hostlist.py b/deluge/ui/hostlist.py index ee4c7df7c..09130192c 100644 --- a/deluge/ui/hostlist.py +++ b/deluge/ui/hostlist.py @@ -207,13 +207,13 @@ class HostList(object): host_id, host, port, user = self.get_host_info(host_id) except ValueError: log.warning('Problem getting host_id info from hostlist') - return status_offline + return defer.succeed(status_offline) try: ip = gethostbyname(host) except gaierror as ex: log.error('Error resolving host %s to ip: %s', host, ex.args[1]) - return status_offline + return defer.succeed(status_offline) host_conn_info = ( ip, -- cgit