summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-03-27 09:30:56 -0400
committerGitHub <noreply@github.com>2019-03-27 09:30:56 -0400
commit5d2b02532a27c4a6ae7622b1be2380c9e143461e (patch)
tree72daf34137a6321fa5659b6a859f17dfde30d1d5
parentc3eaf0f1d641c36d1ffd4316dfa35889dfb8a30a (diff)
parent8e1325d97ffc9d84f9d757ab99ae1a291df24b8e (diff)
downloadcherrypy-git-5d2b02532a27c4a6ae7622b1be2380c9e143461e.tar.gz
Merge pull request #1774 from cherrypy/bugfix/1759-revertv18.1.1
Revert "publish should be called when the state is changed"
-rw-r--r--CHANGES.rst6
-rw-r--r--cherrypy/process/wspbus.py2
-rw-r--r--cherrypy/test/test_bus.py28
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)