INNER CODE UNIT · Python
_phase
BlessedRebuS/Krawl · src/app.py:28
def _phase(app_logger, name: str, fatal: bool = False):
"""Log a startup phase with its duration, and never let it stall silently.
Boot used to run eight hand-rolled try/excepts that only logged on success,
so a slow phase (the database cleanup, typically) looked like a hang right
after "Database ready". Now every phase announces itself before it runs.
Non-fatal phases log the failure and let startup continue, matching the
previous behaviour; `fatal=True` re-raises.
"""
app_logger.info(f"→ {name}")
t0 = time.monotonic()
try:
yield
except Exception as e:
app_logger.error(f"✗ {name} failed after {time.monotonic() - t0:.1f}s: {e}")
if fatal:
raise