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.
pip install aftercarefrom 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)- LIFO cleanup matches resource acquisition order
- One failed cleanup does not skip the rest
- Results recorded for ops / tests via
ac.results
| 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 |
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 |
pip install -e ".[dev]"
pytest -q
ruff check .
mypy srcThis 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
MIT © Coldbricks — coldbricks@gmail.com