summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2020-04-27 16:14:17 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2020-04-27 16:24:33 +0100
commitd02fa72e8013b31c17d8adc6d44f6cb259169f8e (patch)
tree03e653031a63568f0a4509b1562262c3ca6a8737
parent62d8749e7404f247494fd091f8a17a1c58735606 (diff)
downloaddeluge-d02fa72e8013b31c17d8adc6d44f6cb259169f8e.zip
deluge-d02fa72e8013b31c17d8adc6d44f6cb259169f8e.tar.gz
deluge-d02fa72e8013b31c17d8adc6d44f6cb259169f8e.tar.bz2
[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.
-rw-r--r--deluge/ui/console/modes/connectionmanager.py12
-rw-r--r--deluge/ui/hostlist.py4
2 files changed, 7 insertions, 9 deletions
diff --git a/deluge/ui/console/modes/connectionmanager.py b/deluge/ui/console/modes/connectionmanager.py
index 84a3fbc..a5c5968 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 ee4c7df..0913019 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,