~n0mn0m/PostgresAdvisoryLock

Python AsyncIO advisory lock in Postgres
13cbd17b — Alexander Hagerman 10 months ago
Update lock to provide retry functionality.
c3da964e — Alexander Hagerman 10 months ago
Update lock functionality.
60ed495c — Alexander Hagerman 10 months ago
Merge pull request #3 from AlexHagerman/license-doc-update

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~n0mn0m/PostgresAdvisoryLock
read/write
git@git.sr.ht:~n0mn0m/PostgresAdvisoryLock

You can also use your local clone with git send-email.

Getting Started

This repo provides an asyncio wrapper for using Postgres Advisory locks in your project.

To get stated run the test suite:

python3 -m venv ~/.virtualenv/advisory_locks
source ~/.virtualenv/advisory_locks
pip install -r requirements.txt
source env.sh
docker-compose up -d
python3 -m unittest test_postgres.py

Example:

from postgres import AdvisoryLock, DatabaseConfig

dbconfig = DatabaseConfig()

async with AdvisoryLock("gold_leader", dbconfig) as connection:
    # application code

For more information see the blog post.