caesura 📜
Mid-execution distributed locking with zero boilerplate.
Standard distributed locks force you to wrap your entire function in a with block, even if you need heavy parsing or database lookups just to find out what needs locking. caesura lets you safely acquire locks mid-execution: yield signals exactly where the blocking I/O happens, and the decorator manages teardown—even on crash.
uv add caesura
Why
| Concept | Standard Context Managers | caesura |
|---|---|---|
| Lock Boundary | The entire function. | Exactly where it matters. |
| Deadlock Prevention | Manual ordering required. | Mathematically guaranteed via tuples. |
| Infrastructure Coupling | High (imports Redis/Postgres). | Zero (accepts any context manager). |
| Type Visibility | Lost behind the wrapper. | See-through: signature & return preserved. |
Usage
import caesura
@caesura.serialize
def process_webhook(payload):
parsed_data = heavy_json_parse(payload) # lock-free work first
yield redis.lock(f"user:{parsed_data.user_id}") # hand the lock to the decorator
db.update_balance(parsed_data.user_id) # resumes safely locked
return True # locks released on return — or on crash — via Python's ExitStack
Deadlock Prevention
Yield multiple resources as a tuple. caesura sorts them by their name (falling back to str()) and acquires them in an identical, deterministic order across all workers — making deadlocks mathematically impossible.
@caesura.serialize
def transfer_funds(sender_id, receiver_id):
yield (redis.lock(sender_id), redis.lock(receiver_id)) # sorted before acquiring
db.execute_transfer(sender_id, receiver_id)
Metadata
Release files for caesura 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| caesura-1.0.0.tar.gz | 3.0 kB | Without provenance | Details for caesura-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| caesura-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for caesura-1.0.0-py3-none-any.whl |
Total release size: 6.7 kB
Release files / caesura-1.0.0.tar.gz
| Download URL | caesura-1.0.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d41b379cf22abcb34a5166ae21b59ffa3cb3c67829390b1628b5b4e3ddbb67b
|
|
BLAKE2b-256 checksum How to use checksums |
dc9f50f774dc5ede5d97e0e527ad36124d34ad2be5b81bfdf47f8417410a571d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / caesura-1.0.0-py3-none-any.whl
| Download URL | caesura-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ee0aa8882b3eb6a10c79034e4142dc8c98cd19917be5116aebcacbe96452b5d
|
|
BLAKE2b-256 checksum How to use checksums |
c9a54073f0de7edea2fc9eacd902215bb36430b03cf20b43fda1a770b21d11df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for caesura 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.