Skip to content

publish should be called when the state is changed - #1759

Merged
jaraco merged 2 commits into
cherrypy:masterfrom
ian-otto:duper51-patch-1
Dec 9, 2018
Merged

publish should be called when the state is changed#1759
jaraco merged 2 commits into
cherrypy:masterfrom
ian-otto:duper51-patch-1

Conversation

@ian-otto

Copy link
Copy Markdown
Contributor

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?

  • bug fix
  • feature
  • docs update
  • tests/coverage improvement
  • refactoring
  • other

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:

  • I think the code is well written
  • I wrote good commit messages
  • I have squashed related commits together after the changes have been approved
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Documentation reflects the changes
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences

publish should not be called during every wait cycle, only after the wait has found the correct state

@webknjaz webknjaz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, I'm not sure about the impact of this change. Let's see what @jaraco thinks.

while self.state not in states:
time.sleep(interval)
self.publish(channel)
self.publish(channel)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible this was just an error that was propagated to other libraries? Is there a commit somewhere where that was specifically added?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jaraco

jaraco commented Dec 9, 2018

Copy link
Copy Markdown
Member

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.

@jaraco

jaraco commented Dec 9, 2018

Copy link
Copy Markdown
Member

I removed the publish call altogether:

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
jaraco merged commit 4515443 into cherrypy:master Dec 9, 2018

@jaraco jaraco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the code in a simple comment. Leaving this comment to close the requested review.

@jaraco

jaraco commented Dec 9, 2018

Copy link
Copy Markdown
Member

This change is being released as v18.1.0.

@webknjaz

webknjaz commented Dec 9, 2018

Copy link
Copy Markdown
Member

Thanks, I also was confused by all of this and wasn't confident about accepting it myself. The decision to remove it seems fair.

@jaraco

jaraco commented Mar 26, 2019

Copy link
Copy Markdown
Member

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.

@webknjaz

webknjaz commented Apr 8, 2019

Copy link
Copy Markdown
Member

Right, even integration with other things like http://docs.cherrypy.org/en/latest/deploy.html#tornado requires that.

@jaraco can we just have if channel == 'main': self.publish() there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants