demystify-events
Durable jobs and events for Python — the asyncio mirror of the TypeScript @demystify/events runtime. Postgres-backed (pgmq) with a transactional outbox, idempotent consumers, exponential backoff + full jitter retries, and a dead-letter queue — with a full-fidelity in-memory driver so the same code runs offline with no database.
Part of the Demystify Core Services suite.
Install
pip install demystify-events
# real Postgres driver (psycopg + connection pool):
pip install "demystify-events[pg]"
Quickstart (offline, no database)
from demystify_events import create_events_client
from demystify_events.adapters.memory import MemoryQueueDriver
client = create_events_client(driver=MemoryQueueDriver())
# enqueue a job
await client.enqueue("email.send", {"to": "user@example.com"})
# process it (idempotent, retried with backoff+jitter, DLQ on poison)
async def handler(ctx, job):
... # do work; effects committed in the same transaction as the ack
await client.work("email.send", handler)
Switch to real Postgres by passing the psycopg driver (from the [pg] extra)
with a database_url — the handler contract is identical.
Postgres requirements
PsycopgPgmqDriver runs on the pgmq Postgres
extension — install it in the target database first (CREATE EXTENSION pgmq;).
Stock postgres images do not ship pgmq; use one that does, e.g.
ghcr.io/demystify-systems/postgres-pgvector-pgmq (ours, pgvector + pgmq
combined) or quay.io/tembo/pg16-pgmq. If the extension is missing, driver
operations raise an actionable RuntimeError ("pgmq extension not available in
this database. Run CREATE EXTENSION pgmq; ...") with the original psycopg error
chained as __cause__, instead of a cryptic
relation "pgmq.q_x" does not exist.
MemoryQueueDriver (alias EphemeralQueueDriver — the same class) is
ephemeral: jobs live in process memory and are lost on restart. Outside
pytest runs its constructor emits a warnings.warn once per process; set
DMSTFY_EVENTS_ALLOW_EPHEMERAL=1 to silence it when running in-memory on
purpose.
What's in the box
create_events_client/EventsClient— enqueue, transactionalenqueue_in_tx, workerscontract_backoff,full_jitter_backoff,BackoffConfig— retry schedulesContractRegistry— JSON-schema event-type validationmake_envelope/validate_envelope— canonical event envelopes- Adapters:
MemoryQueueDriver(offline) andpsycopg(Postgres/pgmq)
The published wheel is self-contained — it does not vendor
demystify-platform-contracts; contract convergence is asserted by the test
suite. See the module README
for the delivery guarantees, chaos-test results, and the /ops/v1 API.
License
MIT © Demystify Systems
Metadata
Release files for demystify-events 0.3.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 |
|---|---|---|---|---|
| demystify_events-0.3.0.tar.gz | 113.3 kB | With provenance | Details for demystify_events-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| demystify_events-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for demystify_events-0.3.0-py3-none-any.whl |
Total release size: 154.6 kB
Release files / demystify_events-0.3.0.tar.gz
| Download URL | demystify_events-0.3.0.tar.gz |
|---|---|
| Size | 113.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58c13ccad25ee278b9a0aac5f18f6f86e77b5b0e3ad325d05c82160a73f999f1
|
|
BLAKE2b-256 checksum How to use checksums |
7db26ea4f635aae8282df53ff87f237e21a06050cab851658660e42cd851903c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.
Transparency logRelease files / demystify_events-0.3.0-py3-none-any.whl
| Download URL | demystify_events-0.3.0-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04b97a849f157b9543e8facafcc1cca361f6b2498b199aafc6af65c0fc0ddb75
|
|
BLAKE2b-256 checksum How to use checksums |
965b33e827a889a80212e8405a29a9e9440ff0e4b28f6bfaa65443e3f7a16001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.
Transparency logSecurity for demystify-events 0.3.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for demystify_events-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.
Transparency logA 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.