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

Bug: Timeout cannot be passed in as zero #11

Open
jae-lee opened this issue Jan 6, 2021 · 1 comment
Open

Bug: Timeout cannot be passed in as zero #11

jae-lee opened this issue Jan 6, 2021 · 1 comment

Comments

@jae-lee
Copy link

jae-lee commented Jan 6, 2021

https://github.com/percolate/redset/blob/master/redset/locks.py#L60

Because self.timeout is evaluated as timeout or 10, if timeout is passed in as 0, 0 is a false-y value, and incorrectly gets set to 10.

@Montana
Copy link

Montana commented May 4, 2022

Let's just say an int of 0 or a float of 0.0 is an empty list/tuple/dict/set, an empty string or byte, a None (or in this case 0) are all falsey in Python, meaning they ultimately are all going to be evaluated as false.

This rule is fairly general. None, 0, [], {}, empty containers in general, etc., are all "falsey", while anything else is "truthy".

In [6]: bool(None)
Out[6]: False

In [7]: bool([])
Out[7]: False

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

No branches or pull requests

2 participants