publish should be called when the state is changed - #1759
Conversation
publish should not be called during every wait cycle, only after the wait has found the correct state
| while self.state not in states: | ||
| time.sleep(interval) | ||
| self.publish(channel) | ||
| self.publish(channel) |
There was a problem hiding this comment.
Remark: I've checked magicbus and it also has publish inside of the loop.
https://github.com/cherrypy/magicbus/blob/master/magicbus/base.py#L335
cc @aminusfu
There was a problem hiding this comment.
Is it possible this was just an error that was propagated to other libraries? Is there a commit somewhere where that was specifically added?
There was a problem hiding this comment.
Yea.. It's a huge wholesale decade old commit: f5d026c#diff-be33a4f55d59dfc70fc6452482f3a7a4R291. Sure it got into magicbus after cherrypy.
But it's hard to guess what was the reason for putting it like this. That's why I'm tagging guys who might know better.
cc @jaraco
|
Sorry to let this linger so long. I've reviewed this superficially twice but I continue to feel like there's no clear answer. I agree the code itself seems wrong. What I'm struggling with is determining what this code is intended to do and if it still accomplishes the intention in this new form. I'm trying to devise a test or some other action to improve my confidence in the change. |
|
I removed the diff --git a/cherrypy/process/wspbus.py b/cherrypy/process/wspbus.py
index 8f762ef0..4af4c752 100644
--- a/cherrypy/process/wspbus.py
+++ b/cherrypy/process/wspbus.py
@@ -375,7 +375,6 @@ class Bus(object):
while self.state not in states:
time.sleep(interval)
- self.publish(channel)
def _do_execv(self):
"""Re-execute the current process.Then ran the CherryPy tests, and they all passed. That suggests to me that this code isn't covered by the tests and isn't essential to CherryPy in its typical use. Given our inability to test this functionality, I'm inclined to rely on the evidence described in the ticket for why this change produces a preferred behavior and accept it. |
jaraco
left a comment
There was a problem hiding this comment.
I reviewed the code in a simple comment. Leaving this comment to close the requested review.
|
This change is being released as v18.1.0. |
|
Thanks, I also was confused by all of this and wasn't confident about accepting it myself. The decision to remove it seems fair. |
|
We need to revert this change. As discovered in cherrypy/cheroot#99 and declared by the docs, the 'main' event is supposed to fire periodically. After this change, the 'main' event no longer fires periodically. |
|
Right, even integration with other things like http://docs.cherrypy.org/en/latest/deploy.html#tornado requires that. @jaraco can we just have |
publish should not be called during every wait cycle, only after the wait has found the correct state
What kind of change does this PR introduce?
What is the related issue number (starting with
#)#1758
What is the current behavior? (You can also link to an open issue here)
#1758
What is the new behavior (if this is a feature change)?
N/A
Other information:
Checklist:
and description in grammatically correct, complete sentences