Update lingering references to with_broker & run_with_broker
A previous commit renamed run_with_broker() and with_broker() to run_with_router() and with_router() respctively. Some references were missed.
This commit is contained in:
parent
dc26460a28
commit
d706b7d6b8
|
@ -45,7 +45,7 @@ def log_to_file(path=None, io=True, level='INFO'):
|
||||||
|
|
||||||
|
|
||||||
def run_with_router(func, *args, **kwargs):
|
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
|
:py:class:`mitogen.master.Router`, ensuring the Router and Broker are
|
||||||
correctly shut down during normal or exceptional return."""
|
correctly shut down during normal or exceptional return."""
|
||||||
broker = mitogen.master.Broker()
|
broker = mitogen.master.Broker()
|
||||||
|
@ -58,12 +58,12 @@ def run_with_router(func, *args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def with_router(func):
|
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
|
.. code-block:: python
|
||||||
|
|
||||||
@with_broker
|
@with_router
|
||||||
def do_stuff(broker, arg):
|
def do_stuff(router, arg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
do_stuff(blah, 123)
|
do_stuff(blah, 123)
|
||||||
|
|
|
@ -8,9 +8,9 @@ import mitogen.master
|
||||||
import mitogen.utils
|
import mitogen.utils
|
||||||
|
|
||||||
|
|
||||||
@mitogen.utils.with_broker
|
@mitogen.utils.with_router
|
||||||
def do_stuff(broker):
|
def do_stuff(router):
|
||||||
context = mitogen.master.connect(broker)
|
context = router.connect(mitogen.master.Stream)
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
ncalls = 1000
|
ncalls = 1000
|
||||||
for x in xrange(ncalls):
|
for x in xrange(ncalls):
|
||||||
|
|
|
@ -6,27 +6,27 @@ import mitogen.master
|
||||||
import mitogen.utils
|
import mitogen.utils
|
||||||
|
|
||||||
|
|
||||||
def func0(broker):
|
def func0(router):
|
||||||
return broker
|
return router
|
||||||
|
|
||||||
|
|
||||||
@mitogen.utils.with_broker
|
@mitogen.utils.with_router
|
||||||
def func(broker):
|
def func(router):
|
||||||
return broker
|
return router
|
||||||
|
|
||||||
|
|
||||||
class RunWithBrokerTest(unittest.TestCase):
|
class RunWithRouterTest(unittest.TestCase):
|
||||||
# test_shutdown_on_exception
|
# test_shutdown_on_exception
|
||||||
# test_shutdown_on_success
|
# test_shutdown_on_success
|
||||||
|
|
||||||
def test_run_with_broker(self):
|
def test_run_with_broker(self):
|
||||||
broker = mitogen.utils.run_with_broker(func0)
|
router = mitogen.utils.run_with_router(func0)
|
||||||
self.assertTrue(isinstance(broker, mitogen.master.Broker))
|
self.assertTrue(isinstance(router, mitogen.master.Router))
|
||||||
self.assertFalse(broker._thread.isAlive())
|
self.assertFalse(router.broker._thread.isAlive())
|
||||||
|
|
||||||
|
|
||||||
class WithBrokerTest(unittest.TestCase):
|
class WithRouterTest(unittest.TestCase):
|
||||||
def test_with_broker(self):
|
def test_with_broker(self):
|
||||||
broker = func()
|
router = func()
|
||||||
self.assertTrue(isinstance(broker, mitogen.master.Broker))
|
self.assertTrue(isinstance(router, mitogen.master.Router))
|
||||||
self.assertFalse(broker._thread.isAlive())
|
self.assertFalse(router.broker._thread.isAlive())
|
||||||
|
|
Loading…
Reference in New Issue