`bulk_update_or_create` for Django model managers
Project description
django-bulk-update-or-create
Distributed locks for Django using DB (MySQL/Postgres)
Given the limitation that Percona Cluster does not support MySQL locks,
this app implements locks using select_for_update()
(row
locks).
Installation
pip install django-database-locks
Usage
from django.core.management.base import BaseCommand
from database_locks import locked
@locked
class Command(BaseCommand):
...
def handle(self, *args, **options):
self.stdout.write('Got the lock')
Docs
Both [lock]{.title-ref} and [locked]{.title-ref} have the same optional args:
:param lock_name: unique name in DB for this function
:param timeout: numbers of seconds to wait to acquire lock
:param lock_ttl: expiration timer of the lock, in seconds (set to None to infinite)
:param locked_by: owner id for the lock (if lock is active but owner is the same, returns acquired)
:param auto_renew: if set to True will re-acquire lock (for `lock_ttl` seconds) before `lock_ttl` is over.
auto_renew thread will raise KeyboardInterrupt on the main thread in case re-acquiring fails
:param retry: retry every `retry` seconds acquiring until successful. set to None or 0 to disable.
:param lost_lock_cb: callback function when lock is lost (when re-acquiring). defaults to raising LockException
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-bulk-update-or-create-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 845a899aff699b05113c575b460621fb93baada8f18bb7aa59dbb4ad54b55e70 |
|
MD5 | 57d3dee2b8d5a1496d62d546c19fe930 |
|
BLAKE2b-256 | 90bd66369c8cfdc7b77fa6d45e24cb09ce6171dc250d146099692019dc2ca6db |
Close
Hashes for django_bulk_update_or_create-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18ce5ab25b679328d20c59e9df45521dd2e9bcda89aae514e0c06f9b6582d87e |
|
MD5 | b0157ca5a79b261d0c2b1d7f9d7f2f5a |
|
BLAKE2b-256 | 17cbd05bfb93bb2a462bea1da4eeaa76e96b80edf0f00989140fa876782e8284 |