{"repo":"seankerr/py-postgresql-lock","free":true,"listed":false,"github":"https://github.com/seankerr/py-postgresql-lock","clone":"git clone https://github.com/seankerr/py-postgresql-lock.git","description":"Lock mechanism implemented with PostgreSQL advisory locks.","language":"Python","stars":16,"topics":["postgres","postgresql","lock","python","distributed-lock","advisory-lock"],"license":"BSD-3-Clause","category":"databases-storage","readme_excerpt":"postgresql-lock Lock mechanism implemented with PostgreSQL advisory locks. Easily implement distributed database locking. Install Supported database interfaces - asyncpg - asynchronous - psycopg2 - synchronous - psycopg3 - asynchronous - synchronous - sqlalchemy (supports version 1 & 2; can use any underlying database interface) - asynchronous - synchronous Why would I use this? - PostgreSQL table locks aren't sufficient for your use-case - PostgreSQL row locks don't work on INSERT - You want to prevent race conditions between INSERT and UPDATE on the same primary key - None of the aforementioned details fit your use-case, but you have PostgreSQL installed and need to prevent race conditions in a distributed system Default operation By default postgresql-lock will use session lock scope in blocking mode with rollback on error enabled. The session lock scope means only a single database connection can acquire the lock at a time. Usage All work revolves around the Lock class. The easiest way to use Lock is with with or async with statements. The lock will be released automatically. If rollback on error is enabled (default), rollbacks are automatically handled prior to release. Using with and async with implies blocking mode. Now compare the above example to the equivalent try/finally example below: Asynchronous usage (without async with ) Non-blocking mode (supports async as well) Specify the database interface manually Handle rollbacks manually Changelog - 0.2.2 - Fix: error r","default_branch":null,"files":null,"tree":[],"storefront":"/r/seankerr","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/seankerr/py-postgresql-lock/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."}