{"repo":"AmbitionEng/django-pglock","free":true,"listed":false,"github":"https://github.com/AmbitionEng/django-pglock","clone":"git clone https://github.com/AmbitionEng/django-pglock.git","description":"Postgres advisory locks, table locks, and blocking lock management.","language":"Python","stars":70,"topics":["django","locks","postgresql"],"license":"BSD-3-Clause","category":"databases-storage","readme_excerpt":"django-pglock django-pglock performs advisory locks, table locks, and helps manage blocking locks. Here's some of the functionality at a glance: pglock.advisory for application-level locking, for example, ensuring that tasks don't overlap. pglock.model for locking an entire model. pglock.timeout for dynamically setting the timeout to acquire a lock. pglock.prioritize to kill blocking locks for critical code, such as migrations. The PGLock and BlockedPGLock models for querying active and blocked locks. The pglock management command that wraps the models and provides other utilities. Quickstart Advisory Locks Use pglock.advisory to acquire a Postgres advisory lock: Above our code will block until the lock is available, meaning no instances of the function will run simultaneously. Use the timeout argument to configure how long to wait for the lock. A timeout of zero will return immediately: Use side effect=pglock.Raise to raise a django.db.utils.OperationalError if the lock can't be acquired. When using the decorator, you can also use side effect=pglock.Skip to skip the function if the lock can't be acquired: Model Locks pglock.model can take a lock on an entire model during a transaction. For example: pglock.model uses Postgres's LOCK statement, and it accepts the lock mode as a argument. See the Postgres docs for more information. Note pglock.model is similar to pglock.advisory . Use the timeout argument to avoid waiting for locks, and supply the appropriate side effect to adj","default_branch":null,"files":null,"tree":[],"storefront":"/r/AmbitionEng","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/AmbitionEng/django-pglock/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}