[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.
This commit is contained in:
parent
62d8749e74
commit
d02fa72e80
|
@ -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):
|
||||
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():
|
||||
|
||||
def on_host_status(status_info):
|
||||
self.statuses[status_info[0]] = status_info
|
||||
self.update_select_host_popup()
|
||||
|
||||
self.hostlist.get_host_status(host_entry[0]).addCallback(on_host_status)
|
||||
|
||||
def _on_connected(self, result):
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue