asyncpg-lock
Run long-running work exclusively using PostgreSQL advisory locks.
Usage
import asyncio
import asyncpg
import asyncpg_lock
async def worker_func() -> None:
# something very long-running
while True:
await asyncio.sleep(100500)
async def main():
guard = asyncpg_lock.AdvisoryLockGuard(
connect=lambda: asyncpg.connect("postgresql://localhost/db")
)
# worker_func will not be executed concurrently
key = 100500
tasks = [
asyncio.create_task(guard.run(key, worker_func)),
asyncio.create_task(guard.run(key, worker_func)),
asyncio.create_task(guard.run(key, worker_func)),
asyncio.create_task(guard.run(key, worker_func))
]
await asyncio.gather(*tasks)
asyncio.run(main())
Metadata
Release files for asyncpg-lock 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asyncpg_lock-0.0.3.tar.gz | 35.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asyncpg_lock-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.1 kB
Release files / asyncpg_lock-0.0.3.tar.gz
| Download URL | asyncpg_lock-0.0.3.tar.gz |
|---|---|
| Size | 35.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ce6946cb82def5ebb9b9ae3d49b57e1428db35e34efe79f25315468d8f26dee
|
|
BLAKE2b-256 checksum How to use checksums |
969879ab8c394337229ad3e59cce06c3753e4532b86eb8d786d5d46958323799
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / asyncpg_lock-0.0.3-py3-none-any.whl
| Download URL | asyncpg_lock-0.0.3-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9834247bf48caea93f50c6da5bcf52369aa3e8e6ebf5f18f8b8b1639a4d3fe41
|
|
BLAKE2b-256 checksum How to use checksums |
bb085f7382a7ae5bb20e9feca3ece6468d0ab391414b68499f58b687a0d7be6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|