next-resolver (Python)
A utility to simplify the repeated unique ID + async promise pattern, built on asyncio.
Install from PyPI:
pip install next-resolver
Basic usage
from next_resolver import next_resolver
next_fn, resolve = next_resolver()
# next unique identifier and its awaitable
uid, promise = next_fn()
# pass `promise` around, keep `uid` …
# … then when the work is done:
if condition:
resolve(uid, value)
# or reject:
if error:
resolve(uid, None, error=ValueError("reason"))
promise is a Promise (subclass of asyncio.Future). Await it like any other future:
result = await promise
Custom ID types
The factory accepts a callable typed (default: int) that turns a running counter into an ID. Use str for string IDs, or any hashable value suitable for use as a dict key:
next_fn, resolve = next_resolver(str)
uid, promise = next_fn()
assert isinstance(uid, str)
next_fn, resolve = next_resolver(lambda n: f"job-{n}")
uid, promise = next_fn()
If the callable can still collide with an existing ID, the implementation increments and tries again until the ID is unused—so keep ID creation cheap and deterministic per counter value.
Promise
Promise extends asyncio.Future and adds chaining similar to JavaScript promises:
then(on_fulfilled, on_rejected=None)— returns anotherPromisecatch(on_rejected)— rejection-only handler
Nested Promise values can be flattened with the async helper Promise.value(promise).
Requirements
Python 3.8+
See also
The repository README documents the JavaScript package of the same name.
Metadata
Release files for next-resolver 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 | Provenance | |
|---|---|---|---|---|
| next_resolver-0.0.3.tar.gz | 4.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| next_resolver-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / next_resolver-0.0.3.tar.gz
| Download URL | next_resolver-0.0.3.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04b47b2ceb65dc02061396f20a9036a5c4e1574b1672a006a9bcbed013de498c
|
|
BLAKE2b-256 checksum How to use checksums |
bc94fc4391080df147fa8ff3813a84689472f508086726cb0c9db813706f5bd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / next_resolver-0.0.3-py3-none-any.whl
| Download URL | next_resolver-0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
104d25f388368b7108e97717e81506a8739e6ad69449319b44223b2066304432
|
|
BLAKE2b-256 checksum How to use checksums |
f5ce5dbf34300c5e123f2711277f84217913fc40abca1c141386a01538f88ab9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for next-resolver 0.0.3
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.