Skip to content

Commit

Permalink
Merge pull request #12 from RomuloOliveira/ro-documentation-fix
Browse files Browse the repository at this point in the history
Use the correct lock attribute in documentation
  • Loading branch information
renanivo committed Oct 5, 2016
2 parents 3734d50 + 2542155 commit 0ebbcbf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/concurrent.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ from django_toolkit.concurrent.locks import CacheLock

def run(*args, **kwargs):
with CacheLock(key='key') as lock:
assert lock.is_active
assert lock.active
# do some stuff
```

Expand All @@ -80,17 +80,19 @@ def run(*args, **kwargs):
```

You can control lock to don't raise `LockActiveError` exception.
The attribute `active` will indicate whether lock acquiring was successful or
not.

```python
from django_toolkit.concurrent.locks import CacheLock

def run(*args, **kwargs):
with CacheLock(key='key', raise_exception=False) as lock:
assert lock.is_active
assert lock.active

with CacheLock(key='key', raise_exception=False) as lock:
if lock.is_active:
# do some stuff
if lock.active:
# do some stuff, lock is now active
else:
# do some stuff
# do other stuff, lock was not acquired
```

0 comments on commit 0ebbcbf

Please sign in to comment.