-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
36 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '2.1.0' | ||
__version__ = '2.1.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from contextlib import contextmanager | ||
from django.conf import settings | ||
from redis import Redis | ||
from redis.lock import Lock | ||
from typing import Generator | ||
|
||
|
||
@contextmanager | ||
def redis_lock(name: str, **kwargs) -> Generator: | ||
""" | ||
Acquire a Redis lock. This is a wrapper around redis.lock.Lock(), that also works in tests (there, the lock is | ||
always granted without any checks). | ||
Relevant kwargs are: | ||
- blocking_timeout: how many seconds to try to acquire the lock. Use 0 for a non-blocking lock. | ||
The default is None, which means we wait forever. | ||
- timeout: how many seconds to keep the lock for. The default is None, which means it remains locked forever. | ||
Raises redis.exceptions.LockError if the lock couldn't be acquired or released. | ||
""" | ||
if settings.DJTRIGGERS_REDIS_URL.startswith('redis'): # pragma: no cover | ||
with Lock(redis=Redis.from_url(settings.DJTRIGGERS_REDIS_URL), name=name, **kwargs): | ||
yield | ||
else: | ||
yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
license='BSD', | ||
description='Framework to create and process triggers.', | ||
long_description=open('README.md', 'r').read(), | ||
long_description_content_type='text/markdown', | ||
author='Unleashed NV', | ||
author_email='[email protected]', | ||
packages=find_packages('.'), | ||
|