diff --git a/mitogen/utils.py b/mitogen/utils.py index f67125af..1afd9a80 100644 --- a/mitogen/utils.py +++ b/mitogen/utils.py @@ -45,7 +45,7 @@ def log_to_file(path=None, io=True, level='INFO'): def run_with_router(func, *args, **kwargs): - """Arrange for `func(broker, *args, **kwargs)` to run with a temporary + """Arrange for `func(router, *args, **kwargs)` to run with a temporary :py:class:`mitogen.master.Router`, ensuring the Router and Broker are correctly shut down during normal or exceptional return.""" broker = mitogen.master.Broker() @@ -58,12 +58,12 @@ def run_with_router(func, *args, **kwargs): def with_router(func): - """Decorator version of :py:func:`run_with_broker`. Example: + """Decorator version of :py:func:`run_with_router`. Example: .. code-block:: python - @with_broker - def do_stuff(broker, arg): + @with_router + def do_stuff(router, arg): pass do_stuff(blah, 123) diff --git a/tests/timing_test.py b/tests/timing_test.py index 36bb9da7..e89fc3a9 100644 --- a/tests/timing_test.py +++ b/tests/timing_test.py @@ -8,9 +8,9 @@ import mitogen.master import mitogen.utils -@mitogen.utils.with_broker -def do_stuff(broker): - context = mitogen.master.connect(broker) +@mitogen.utils.with_router +def do_stuff(router): + context = router.connect(mitogen.master.Stream) t0 = time.time() ncalls = 1000 for x in xrange(ncalls): diff --git a/tests/utils_test.py b/tests/utils_test.py index 6fc25e8c..2f0c1f08 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -6,27 +6,27 @@ import mitogen.master import mitogen.utils -def func0(broker): - return broker +def func0(router): + return router -@mitogen.utils.with_broker -def func(broker): - return broker +@mitogen.utils.with_router +def func(router): + return router -class RunWithBrokerTest(unittest.TestCase): +class RunWithRouterTest(unittest.TestCase): # test_shutdown_on_exception # test_shutdown_on_success def test_run_with_broker(self): - broker = mitogen.utils.run_with_broker(func0) - self.assertTrue(isinstance(broker, mitogen.master.Broker)) - self.assertFalse(broker._thread.isAlive()) + router = mitogen.utils.run_with_router(func0) + self.assertTrue(isinstance(router, mitogen.master.Router)) + self.assertFalse(router.broker._thread.isAlive()) -class WithBrokerTest(unittest.TestCase): +class WithRouterTest(unittest.TestCase): def test_with_broker(self): - broker = func() - self.assertTrue(isinstance(broker, mitogen.master.Broker)) - self.assertFalse(broker._thread.isAlive()) + router = func() + self.assertTrue(isinstance(router, mitogen.master.Router)) + self.assertFalse(router.broker._thread.isAlive())