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

Fixing redis locking for 5000 seconds unintentionally #5

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions umeboshi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@


@contextlib.contextmanager
def simple_lock(lock_key, timeout=5000):
Copy link
Contributor

Choose a reason for hiding this comment

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

is 5 sec enough ? should we make it longer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's always been meant to be 5 seconds. the fact that it's locking for 5000 seconds is purely accidental and "bad"

def simple_lock(lock_key, timeout=5000, redis_timeout_sec=5):
markhsu-ms marked this conversation as resolved.
Show resolved Hide resolved
"""
A simple context manager that raises the passed exception
if a lock can't be acquired.
"""

acquire_lock = lambda: cache.add(lock_key, 1, timeout)
acquire_lock = lambda: cache.add(lock_key, 1, redis_timeout_sec)
release_lock = lambda: cache.delete(lock_key)

waited, hops = 0, 10
Expand Down