Skip to content

Repository files navigation

aftercare

PyPI Python Versions CI License: MIT

Teardown orchestration for Python. Register cleanup steps, then run them in reverse order on exit — logging each one's success or failure without short-circuiting the rest.

Install

pip install aftercare

Quickstart

from aftercare import Aftercare

order = []
with Aftercare() as ac:
    ac.add(lambda: order.append("close_db"), name="close_db")
    ac.add(lambda: order.append("flush_cache"), name="flush_cache")
    # main work...

assert order == ["flush_cache", "close_db"]
assert all(r.ok for r in ac.results)

Why this exists

  • LIFO cleanup matches resource acquisition order
  • One failed cleanup does not skip the rest
  • Results recorded for ops / tests via ac.results

API

Symbol Description
Aftercare Context manager for reverse-order cleanup
Aftercare.add(fn, name=...) Register a cleanup step
Aftercare.callback(name=...) Decorator form of add
CleanupResult Per-step name / ok / error

Related packages

Part of the coldbricks micro-library suite (small, typed, zero-dependency helpers):

Package Role
buzzkill Guaranteed shutdown callbacks
aftercare Reverse-order teardown
fluffer Startup pre-warm
edging Token-bucket rate limit
readback Echo-confirmation validation
hearback Output re-validation decorator
agecheck Timezone-correct age thresholds
transponder State broadcast on change

Development

pip install -e ".[dev]"
pytest -q
ruff check .
mypy src

Roadmap

This is an early 0.1.0 release (Alpha) with active development planned:

  • Async cleanup support
  • Timeout and cancel policies
  • Structured result export for ops tooling

License

MIT © Coldbricks — coldbricks@gmail.com

About

Teardown orchestration: reverse-order cleanup with success logging.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages