https://github.com/developersociety/django-postgres-lock
Django Postgres Lock
https://github.com/developersociety/django-postgres-lock
Last synced: 5 months ago
JSON representation
Django Postgres Lock
- Host: GitHub
- URL: https://github.com/developersociety/django-postgres-lock
- Owner: developersociety
- License: bsd-3-clause
- Created: 2020-03-29T21:59:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-09-17T21:29:32.000Z (9 months ago)
- Last Synced: 2025-09-27T18:02:33.816Z (9 months ago)
- Language: Python
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Postgres Lock
A [Django](https://www.djangoproject.com/) management command which will run a command inside a
Postgres lock, ensuring that only a single instance of the inner command will run.
## Installation
Using [pip](https://pip.pypa.io/):
```console
$ pip install django-postgres-lock
```
Edit your Django project's settings module, and add the application to ``INSTALLED_APPS``:
```python
INSTALLED_APPS = [
# ...
"postgres_lock",
# ...
]
```
## Usage
To run clearsessions with the default lock:
```console
$ ./manage.py command_lock -- ./manage.py clearsessions
```
To use a unique lock for this task:
```console
$ ./manage.py command_lock --name clearsessions -- ./manage.py clearsessions
```
To exit immediately if a lock can't be acquired:
```console
$ ./manage.py command_lock --try --name clearsessions -- ./manage.py clearsessions
```
To ignore a lock failure and return a successful exit code:
```console
$ ./manage.py command_lock --try --ignore-fail --name clearsessions -- ./manage.py clearsessions
```