1. cherrypy
  2. magicbus

Commits

Gustavo Picon  committed fad41aa

Don't shadow outer var names

  • Participants
  • Parent commits 4e486dd
  • Branches default

Comments (0)

Files changed (2)

File magicbus/base.py

View file
  • Ignore whitespace
     def wait(self, state, interval=0.1, channel=None):
         """Poll for the given state(s) at intervals; publish to channel."""
         if isinstance(state, (tuple, list)):
-            states = state
+            _states = state
         else:
-            states = [state]
+            _states = [state]
 
         def _wait():
-            while self.state not in states:
+            while self.state not in _states:
                 time.sleep(interval)
                 self.publish(channel)
 
             kwargs = {}
         args = (func,) + args
 
-        def _callback(func, *a, **kw):
+        def _callback(func_, *a, **kw):
             self.wait(states.STARTED)
-            func(*a, **kw)
+            func_(*a, **kw)
         t = threading.Thread(target=_callback, args=args, kwargs=kwargs)
         t.setName('Bus Callback ' + t.getName())
         t.start()

File magicbus/test/test_bus.py

View file
  • Ignore whitespace
     def log(self, bus):
         self._log_entries = []
 
-        def logit(msg, level):
-            self._log_entries.append(msg)
+        def logit(msg_, level):
+            self._log_entries.append(msg_)
         bus.subscribe('log', logit)
 
     def assertLog(self, entries):
             time.sleep(0.2)
             getattr(b, method)()
 
-        for method, states in [('start', [b.states.STARTED]),
+        for method_, states in [('start', [b.states.STARTED]),
                                ('stop', [b.states.STOPPED]),
                                ('start',
                                 [b.states.STARTING, b.states.STARTED]),
                                ('exit', [b.states.EXITING]),
                                ]:
-            threading.Thread(target=f, args=(method,)).start()
+            threading.Thread(target=f, args=(method_,)).start()
             b.wait(states)
 
             # The wait method MUST wait for the given state(s).
 
         # Try a normal message.
         expected = []
-        for msg in ["O mah darlin'"] * 3 + ["Clementiiiiiiiine"]:
-            b.log(msg)
-            expected.append(msg)
+        for _msg in ["O mah darlin'"] * 3 + ["Clementiiiiiiiine"]:
+            b.log(_msg)
+            expected.append(_msg)
             self.assertLog(expected)
 
         # Try an error message