Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix disabling of distributed lock (#2) #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bertosantamaria
Copy link

No description provided.

@bertosantamaria
Copy link
Author

@sibson, this is another attempt at fixing the disabling of the distributed lock via config.

I meant to reopen #102 with these new changes, but couldn't after closing it. Sorry for the noise.

@bertosantamaria
Copy link
Author

Addresses #101

@bertosantamaria
Copy link
Author

@sibson, please let me know if there is anything I can do/change here to help move this along.
Thanks!

Copy link
Owner

@sibson sibson left a comment

Choose a reason for hiding this comment

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

I think this change is good but I'm struggling with understanding the semantics of has_value vs present. I understand one is converting None to default and the other preserves None but something in the naming isn't clicking in my head. Perhaps, adding a docstring to each to better describe their behaviour would help?


def test_disable_lock_key_3(self):
self.app.conf.REDBEAT_LOCK_KEY = None
self.assertTrue("REDBEAT_LOCK_KEY" in self.app.conf.keys())
Copy link
Owner

Choose a reason for hiding this comment

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

Is this necessary? It seems to be testing the assignment we did in the previous line or am I missing some behind the scenes magic?

Copy link
Author

Choose a reason for hiding this comment

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

Oh yes. I'll remove this.

self.assertTrue("redbeat_lock_key" in self.app.conf.keys())
self.conf = RedBeatConfig(self.app)
self.assertEqual(self.conf.lock_key, None)

Copy link
Owner

Choose a reason for hiding this comment

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

Should there be a @pytest.mark.skipif(CELERY_4_OR_GREATER, reason="requires Celery < 4.x") here?

Copy link
Author

Choose a reason for hiding this comment

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

Yup. Will add the skipif

Copy link
Owner

Choose a reason for hiding this comment

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

I've dropped celery 3 support so this maybe simpler to fix.

@@ -21,6 +21,24 @@ def test_lock_timeout(self):
def test_key_prefix_default(self):
self.assertEqual(self.conf.key_prefix, 'redbeat:')

def test_lock_key_default(self):
Copy link
Owner

Choose a reason for hiding this comment

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

To check my understanding, is this the same test as in https://github.com/sibson/redbeat/pull/109/files#diff-423890b7e3c2aa4791f9e203b7f194cbR45? If so I don't think we need to remove it, being explicit here is great.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this tests the same thing and was added to be explicit.

self.assertTrue("REDBEAT_LOCK_KEY" in self.app.conf.keys())
self.conf = RedBeatConfig(self.app)
self.assertEqual(self.conf.lock_key, None)

Copy link
Owner

Choose a reason for hiding this comment

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

Should there be a test_custom_lock_key() or is that covered elsewhere somehow?

Copy link
Author

Choose a reason for hiding this comment

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

Yup. I'll add a test for a custom lock key.

return self.app.conf.first(name, name.upper()) or default

def key_present_or(self, name, default=None):
Copy link
Owner

Choose a reason for hiding this comment

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

Should there be tests for this function?

Copy link
Author

Choose a reason for hiding this comment

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

Definitely. I'll add one.

@sibson sibson added the question label Apr 3, 2019
@yogevyuval
Copy link
Contributor

@sibson @bertosantamaria Any new on this? Can I help? This feature is really needed and currently not working.

@sibson
Copy link
Owner

sibson commented May 13, 2020

Looking at the comment history, this was close to being good to go just needed a few changes and now it has conflicts. If you'd like to start a new PR too address the feedback we could get it merged in favor of this.

@eurbs eurbs mentioned this pull request Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants