[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.statuses = {}
|
||||||
self.all_torrents = None
|
self.all_torrents = None
|
||||||
self.hostlist = HostList()
|
self.hostlist = HostList()
|
||||||
self.update_hosts_status()
|
|
||||||
BaseMode.__init__(self, stdscr, encoding=encoding)
|
BaseMode.__init__(self, stdscr, encoding=encoding)
|
||||||
self.update_select_host_popup()
|
self.update_hosts_status()
|
||||||
|
|
||||||
def update_select_host_popup(self):
|
def update_select_host_popup(self):
|
||||||
selected_index = self.popup.current_selection() if self.popup else None
|
selected_index = self.popup.current_selection() if self.popup else None
|
||||||
|
@ -71,12 +70,11 @@ class ConnectionManager(BaseMode, PopupsHandler):
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def update_hosts_status(self):
|
def update_hosts_status(self):
|
||||||
for host_entry in self.hostlist.get_hosts_info():
|
|
||||||
|
|
||||||
def on_host_status(status_info):
|
def on_host_status(status_info):
|
||||||
self.statuses[status_info[0]] = status_info
|
self.statuses[status_info[0]] = status_info
|
||||||
self.update_select_host_popup()
|
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)
|
self.hostlist.get_host_status(host_entry[0]).addCallback(on_host_status)
|
||||||
|
|
||||||
def _on_connected(self, result):
|
def _on_connected(self, result):
|
||||||
|
|
|
@ -207,13 +207,13 @@ class HostList(object):
|
||||||
host_id, host, port, user = self.get_host_info(host_id)
|
host_id, host, port, user = self.get_host_info(host_id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
log.warning('Problem getting host_id info from hostlist')
|
log.warning('Problem getting host_id info from hostlist')
|
||||||
return status_offline
|
return defer.succeed(status_offline)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ip = gethostbyname(host)
|
ip = gethostbyname(host)
|
||||||
except gaierror as ex:
|
except gaierror as ex:
|
||||||
log.error('Error resolving host %s to ip: %s', host, ex.args[1])
|
log.error('Error resolving host %s to ip: %s', host, ex.args[1])
|
||||||
return status_offline
|
return defer.succeed(status_offline)
|
||||||
|
|
||||||
host_conn_info = (
|
host_conn_info = (
|
||||||
ip,
|
ip,
|
||||||
|
|
Loading…
Reference in New Issue