Skip to main content

epilogue 📜

Strict execution boundaries for deferred side-effects.

Standard logic forces you to push 3rd-party API calls to the absolute bottom of your functions to prevent partial failures. epilogue lets you queue side-effects during execution, running them only if the core function finishes successfully.

By calling defer(), you register an intent. If the function crashes at any point, the queue is silently destroyed and the error is re-raised. Zero side effects occur.

Usage

import epilogue

@epilogue.atomic
def checkout(user, cart):
    # 1. Register the intent. (Does NOT hit the network yet!)
    epilogue.defer(stripe.charge, user.id, cart.total)

    # 2. Do heavy, crash-prone database logic
    db.save_order(user, cart)

    # 3. Register another intent.
    epilogue.defer(email.send_receipt, user.email)

    return True

    # CHECKPOINT:
    # If db.save_order() throws an Exception, the function crashes normally.
    # The Stripe charge and email are completely aborted.
    # If it returns True, the deferred actions are safely executed in order.
    # If Stripe fails during the epilogue, the email STILL sends, and an ExceptionGroup naturally bubbles up.

Features

  • All-Or-Nothing Safety: Prevent partial failures without writing complex Saga patterns or Kafka queues.
  • Pure Functions: Keeps your core domain logic clean. If you run the code without the decorator (e.g., in unit tests), it just builds a list in memory without triggering real side-effects.
  • Context-Safe by Design: Powered entirely by native contextvars. Topologically safe across concurrent threads, asyncio boundaries, and deep recursion without explicit state tracking.
  • Flawless Fault Propagation: Uses Python 3.11+ ExceptionGroup to guarantee all successful side-effects execute, even if one fails during the epilogue phase.

Installation

uv add epilogue
# or
pip install epilogue

Release files for epilogue 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for epilogue 1.0.0
File Size Uploaded
epilogue-1.0.0.tar.gz 2.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for epilogue 1.0.0
File Interpreter ABI Platform
epilogue-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.7 kB

Release files / epilogue-1.0.0.tar.gz

Download URL epilogue-1.0.0.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9845fd549e15adafed2eb96ae0909ea2c0a0b2ef4091ed554f8c0e99d2bdffc5
BLAKE2b-256 checksum
How to use checksums
efcb20b07c890957143e73f1128032710913bb6a919f1bbf22ed7aa77f06afba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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 / epilogue-1.0.0-py3-none-any.whl

Download URL epilogue-1.0.0-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a9331d8a5e58ca7995624ea5ad77618c57c856e1a1c31e27db93edd488b0928
BLAKE2b-256 checksum
How to use checksums
65c7f02e3eadd065055ffc64b5a756b5b02e0597dc0e70a2ea4ad9a3f06854ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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 history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page