diff options
-rw-r--r-- | CHANGES.rst | 6 | ||||
-rw-r--r-- | cherrypy/process/wspbus.py | 2 | ||||
-rw-r--r-- | cherrypy/test/test_bus.py | 28 |
3 files changed, 28 insertions, 8 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 9da7afa8..7862fc93 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,9 @@ +v18.1.1 +------- + +* :pr:`1774` reverts :pr:`1759` as new evidence emerged that + the original behavior was intentional. Re-opens :issue:`1758`. + v18.1.0 ------- diff --git a/cherrypy/process/wspbus.py b/cherrypy/process/wspbus.py index 5b19b827..ead90a4e 100644 --- a/cherrypy/process/wspbus.py +++ b/cherrypy/process/wspbus.py @@ -374,7 +374,7 @@ class Bus(object): while self.state not in states: time.sleep(interval) - self.publish(channel) + self.publish(channel) def _do_execv(self): """Re-execute the current process. diff --git a/cherrypy/test/test_bus.py b/cherrypy/test/test_bus.py index 6026b47e..12a516c9 100644 --- a/cherrypy/test/test_bus.py +++ b/cherrypy/test/test_bus.py @@ -1,6 +1,6 @@ import threading import time -import unittest +import unittest.mock from cherrypy.process import wspbus @@ -179,12 +179,14 @@ class BusMethodTests(unittest.TestCase): time.sleep(0.2) getattr(b, method)() - for method, states in [('start', [b.states.STARTED]), - ('stop', [b.states.STOPPED]), - ('start', - [b.states.STARTING, b.states.STARTED]), - ('exit', [b.states.EXITING]), - ]: + flow = [ + ('start', [b.states.STARTED]), + ('stop', [b.states.STOPPED]), + ('start', [b.states.STARTING, b.states.STARTED]), + ('exit', [b.states.EXITING]), + ] + + for method, states in flow: threading.Thread(target=f, args=(method,)).start() b.wait(states) @@ -192,6 +194,18 @@ class BusMethodTests(unittest.TestCase): if b.state not in states: self.fail('State %r not in %r' % (b.state, states)) + def test_wait_publishes_periodically(self): + bus = wspbus.Bus() + callback = unittest.mock.MagicMock() + bus.subscribe('main', callback) + + def set_start(): + time.sleep(0.05) + bus.start() + threading.Thread(target=set_start).start() + bus.wait(bus.states.STARTED, interval=0.01, channel='main') + assert callback.call_count > 3 + def test_block(self): b = wspbus.Bus() self.log(b) |