Skip to main content

Strict execution boundaries for deferred side-effects.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epilogue-1.0.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

epilogue-1.0.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file epilogue-1.0.0.tar.gz.

File metadata

  • Download URL: epilogue-1.0.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for epilogue-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9845fd549e15adafed2eb96ae0909ea2c0a0b2ef4091ed554f8c0e99d2bdffc5
MD5 71f9f54472d0eb1b1efc89100976a88a
BLAKE2b-256 efcb20b07c890957143e73f1128032710913bb6a919f1bbf22ed7aa77f06afba

See more details on using hashes here.

File details

Details for the file epilogue-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: epilogue-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for epilogue-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a9331d8a5e58ca7995624ea5ad77618c57c856e1a1c31e27db93edd488b0928
MD5 633b4d6e0c298559dfec07decab850c5
BLAKE2b-256 65c7f02e3eadd065055ffc64b5a756b5b02e0597dc0e70a2ea4ad9a3f06854ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page