Skip to main content

Django Postgres Lock

Project description

A Django 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:

$ pip install django-postgres-lock

Edit your Django project’s settings module, and add the application to INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "postgres_lock",
    # ...
]

Usage

To run clearsessions with the default lock:

$ ./manage.py command_lock -- ./manage.py clearsessions

To use a unique lock for this task:

$ ./manage.py command_lock --name clearsessions -- ./manage.py clearsessions

To exit immediately if a lock can’t be acquired:

$ ./manage.py command_lock --try --name clearsessions -- ./manage.py clearsessions

To ignore a lock failure and return a successful exit code:

$ ./manage.py command_lock --try --ignore-fail --name clearsessions -- ./manage.py clearsessions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-postgres-lock-0.1.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

django_postgres_lock-0.1.1-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page