commit 8b8e97d693d57fec3f8df1f354af0360e7899ab4 Author: Damian Johnson atagar@torproject.org Date: Tue Jul 7 08:40:22 2015 -0700
Perform app resolution as part of updates
Seems we called our _resolve_apps() from the draw loop rather than our update thread. Guess that was so we would only do lookups when viewing the panel? Regardless, the helper has a sleep in it so that's stupid. --- nyx/connections/conn_panel.py | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
diff --git a/nyx/connections/conn_panel.py b/nyx/connections/conn_panel.py index e05a351..f74c245 100644 --- a/nyx/connections/conn_panel.py +++ b/nyx/connections/conn_panel.py @@ -98,9 +98,9 @@ class ConnectionPanel(panel.Panel, threading.Thread):
country_summary = None
- for arg in bridge_clients.split(): - if arg.startswith('CountrySummary='): - country_summary = arg[15:] + for line in bridge_clients.split(): + if line.startswith('CountrySummary='): + country_summary = line[15:] break
if country_summary: @@ -118,10 +118,6 @@ class ConnectionPanel(panel.Panel, threading.Thread):
self._app_resolver = tracker.get_port_usage_tracker()
- # rate limits appResolver queries to once per update - - self.app_resolve_since_update = False - # mark the initially exitsing connection uptimes as being estimates
for entry in self._entries: @@ -417,12 +413,6 @@ class ConnectionPanel(panel.Panel, threading.Thread): for line_number in range(scroll_location, len(self._entry_lines)): entry_line = self._entry_lines[line_number]
- # if this is an unresolved SOCKS, HIDDEN, or CONTROL entry then queue up - # resolution for the applicaitions they belong to - - if isinstance(entry_line, conn_entry.ConnectionLine) and entry_line.is_unresolved_application(): - self._resolve_apps() - # hilighting if this is the selected line
extra_format = curses.A_STANDOUT if entry_line == cursor_selection else curses.A_NORMAL @@ -459,8 +449,6 @@ class ConnectionPanel(panel.Panel, threading.Thread): Fetches the newest resolved connections. """
- self.app_resolve_since_update = False - # if we don't have an initialized resolver then this is a no-op
if not nyx.util.tracker.get_connection_tracker().is_alive(): @@ -576,17 +564,15 @@ class ConnectionPanel(panel.Panel, threading.Thread): self.set_sort_order() self._last_resource_fetch = current_resolution_count
- def _resolve_apps(self, flag_query = True): + self._resolve_apps() + + def _resolve_apps(self): """ Triggers an asynchronous query for all unresolved SOCKS, HIDDEN, and CONTROL entries. - - Arguments: - flag_query - sets a flag to prevent further call from being respected - until the next update if true """
- if self.app_resolve_since_update or not CONFIG['features.connection.resolveApps']: + if not CONFIG['features.connection.resolveApps']: return
unresolved_lines = [l for l in self._entry_lines if isinstance(l, conn_entry.ConnectionLine) and l.is_unresolved_application()] @@ -633,6 +619,3 @@ class ConnectionPanel(panel.Panel, threading.Thread): line.is_application_resolving = False else: line.is_application_resolving = self._app_resolver.is_alive - - if flag_query: - self.app_resolve_since_update = True
tor-commits@lists.torproject.org