[tor-commits] [nyx/master] Mark 'vals_lock' as being private

atagar at torproject.org atagar at torproject.org
Tue Sep 22 17:08:39 UTC 2015


commit f2e6d9340280f0b670c98b3815dd74282a929cbd
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jul 6 08:37:28 2015 -0700

    Mark 'vals_lock' as being private
    
    Several unrevised panels use a lock for its internal state. Marking them all as
    private. I'm doing this as a batch since I needed to double check they weren't
    used externally anyway.
---
 nyx/config_panel.py           |    8 ++++----
 nyx/connections/conn_panel.py |   12 ++++++------
 nyx/torrc_panel.py            |    6 +++---
 nyx/util/tor_config.py        |   13 ++++++-------
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/nyx/config_panel.py b/nyx/config_panel.py
index 58f229b..18d76f4 100644
--- a/nyx/config_panel.py
+++ b/nyx/config_panel.py
@@ -225,7 +225,7 @@ class ConfigPanel(panel.Panel):
     self.conf_contents = []
     self.conf_important_contents = []
     self.scroller = ui_tools.Scroller(True)
-    self.vals_lock = threading.RLock()
+    self._vals_lock = threading.RLock()
 
     # shows all configuration options if true, otherwise only the ones with
     # the 'important' flag are shown
@@ -332,7 +332,7 @@ class ConfigPanel(panel.Panel):
                  set ordering
     """
 
-    with self.vals_lock:
+    with self._vals_lock:
       if ordering:
         CONFIG['features.config.order'] = ordering
 
@@ -358,7 +358,7 @@ class ConfigPanel(panel.Panel):
       self.set_sort_order(result_enums)
 
   def handle_key(self, key):
-    with self.vals_lock:
+    with self._vals_lock:
       if key.is_scroll():
         page_height = self.get_preferred_size()[0] - 1
         detail_panel_height = CONFIG['features.config.selectionDetails.height']
@@ -571,7 +571,7 @@ class ConfigPanel(panel.Panel):
     ]
 
   def draw(self, width, height):
-    with self.vals_lock:
+    with self._vals_lock:
       # panel with details for the current selection
 
       detail_panel_height = CONFIG['features.config.selectionDetails.height']
diff --git a/nyx/connections/conn_panel.py b/nyx/connections/conn_panel.py
index a7b1009..e05a351 100644
--- a/nyx/connections/conn_panel.py
+++ b/nyx/connections/conn_panel.py
@@ -76,7 +76,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     self._last_update = -1        # time the content was last revised
     self._is_tor_running = True   # indicates if tor is currently running or not
     self._halt_time = None        # time when tor was stopped
-    self.vals_lock = threading.RLock()
+    self._vals_lock = threading.RLock()
 
     self._pause_condition = threading.Condition()
     self._halt = False  # terminates thread if true
@@ -158,7 +158,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
                  set ordering
     """
 
-    with self.vals_lock:
+    with self._vals_lock:
       if ordering:
         nyx_config = conf.get_config('nyx')
 
@@ -190,7 +190,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     if self.get_listing_type() == listing_type:
       return
 
-    with self.vals_lock:
+    with self._vals_lock:
       nyx_config = conf.get_config('nyx')
       nyx_config.set('features.connection.listing_type', Listing.keys()[Listing.index_of(listing_type)])
 
@@ -216,7 +216,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
       self.set_sort_order(results)
 
   def handle_key(self, key):
-    with self.vals_lock:
+    with self._vals_lock:
       user_traffic_allowed = tor_controller().is_user_traffic_allowed()
 
       if key.is_scroll():
@@ -367,7 +367,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     return self._scroller.get_cursor_selection(self._entry_lines)
 
   def draw(self, width, height):
-    with self.vals_lock:
+    with self._vals_lock:
       # if we don't have any contents then refuse to show details
 
       if not self._entries:
@@ -469,7 +469,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     conn_resolver = nyx.util.tracker.get_connection_tracker()
     current_resolution_count = conn_resolver.run_counter()
 
-    with self.vals_lock:
+    with self._vals_lock:
       new_entries = []  # the new results we'll display
 
       # Fetches new connections and client circuits...
diff --git a/nyx/torrc_panel.py b/nyx/torrc_panel.py
index 0ed0b96..b0a19da 100644
--- a/nyx/torrc_panel.py
+++ b/nyx/torrc_panel.py
@@ -38,7 +38,7 @@ class TorrcPanel(panel.Panel):
   def __init__(self, stdscr, config_type):
     panel.Panel.__init__(self, stdscr, 'torrc', 0)
 
-    self.vals_lock = threading.RLock()
+    self._vals_lock = threading.RLock()
     self.config_type = config_type
     self.scroll = 0
     self.show_line_num = True     # shows left aligned line numbers
@@ -122,7 +122,7 @@ class TorrcPanel(panel.Panel):
     nyx.popups.show_msg(result_msg, 1)
 
   def handle_key(self, key):
-    with self.vals_lock:
+    with self._vals_lock:
       if key.is_scroll():
         page_height = self.get_preferred_size()[0] - 1
         new_scroll = ui_tools.get_scroll_position(key, self.scroll, page_height, self._last_content_height)
@@ -160,7 +160,7 @@ class TorrcPanel(panel.Panel):
     ]
 
   def draw(self, width, height):
-    with self.vals_lock:
+    with self._vals_lock:
       # If true, we assume that the cached value in self._last_content_height is
       # still accurate, and stop drawing when there's nothing more to display.
       # Otherwise the self._last_content_height is suspect, and we'll process all
diff --git a/nyx/util/tor_config.py b/nyx/util/tor_config.py
index 35ebd24..6bb68b3 100644
--- a/nyx/util/tor_config.py
+++ b/nyx/util/tor_config.py
@@ -822,7 +822,7 @@ class Torrc():
   def __init__(self):
     self.contents = None
     self.config_location = None
-    self.vals_lock = threading.RLock()
+    self._vals_lock = threading.RLock()
 
     # cached results for the current contents
     self.displayable_contents = None
@@ -842,7 +842,7 @@ class Torrc():
                    warning for this before then logs a warning
     """
 
-    with self.vals_lock:
+    with self._vals_lock:
       # clears contents and caches
       self.contents, self.config_location = None, None
       self.displayable_contents = None
@@ -859,7 +859,6 @@ class Torrc():
           log.warn('Unable to load torrc (%s)' % exc.strerror)
           self.is_foad_fail_warned = True
 
-        self.vals_lock.release()
         raise exc
 
   def is_loaded(self):
@@ -882,7 +881,7 @@ class Torrc():
     Provides the contents of the configuration file.
     """
 
-    with self.vals_lock:
+    with self._vals_lock:
       return list(self.contents) if self.contents else None
 
   def get_display_contents(self, strip = False):
@@ -898,7 +897,7 @@ class Torrc():
       strip - removes comments and extra whitespace if true
     """
 
-    with self.vals_lock:
+    with self._vals_lock:
       if not self.is_loaded():
         return None
       else:
@@ -927,7 +926,7 @@ class Torrc():
     results.
     """
 
-    with self.vals_lock:
+    with self._vals_lock:
       if not self.is_loaded():
         return None
       else:
@@ -949,7 +948,7 @@ class Torrc():
     Provides the lock governing concurrent access to the contents.
     """
 
-    return self.vals_lock
+    return self._vals_lock
 
   def log_validation_issues(self):
     """





More information about the tor-commits mailing list