Skip to content

MAINT: Add service shutdown error context - #3281

Merged
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
huong8373tt-beep:fix/p311-08-service-shutdown-context
Oct 19, 2026
Merged

Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
huong8373tt-beep:fix/p311-08-service-shutdown-context

Conversation

@huong8373tt-beep

Copy link
Copy Markdown
Contributor

Description

Implements the remaining service-shutdown investigation for P311-08 from #3166.

When close_services_async collects failures from cached backend service closure and analytics service closure, the original exceptions now receive safe operation-name notes before they are re-raised or grouped. This preserves exception identity, type, traceback, cancellation behavior, ordering, and the existing single-error/BaseExceptionGroup contract.

Tests and Documentation

  • uv run --frozen --no-sync pytest -q --basetemp=D:\oss_contrib\pyrit-p311-08\.pytest-tmp-service-shutdown tests/unit/backend/test_analytics_lifecycle.py — 12 passed.
  • uv run --frozen --no-sync pre-commit run --files pyrit/backend/services/service_lifecycle.py tests/unit/backend/test_analytics_lifecycle.py — passed, including Ruff and ty checks.
  • git diff --check — passed.
  • No documentation changes were needed.

Slai Agent Runtime assisted with investigation, implementation, and tests. The account owner reviewed and authorized this contribution.

@huong8373tt-beep
Slai.life (huong8373tt-beep) force-pushed the fix/p311-08-service-shutdown-context branch from f3d317b to 6164ca6 Compare October 17, 2026 14:14
@ManoharPaturi

Copy link
Copy Markdown
Contributor

Using error.add_note here fits Python 3.11 exception handling nicely. It attaches the specific service closure context without wrapping or altering the underlying exception type, so single error raises keep their exact identity and tracebacks intact while multi failure scenarios retain the existing BaseExceptionGroup structure. The lifecycle tests in test_analytics_lifecycle verify both the single failure and grouped failure cases cleanly.

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 19, 2026
Merged via the queue into microsoft:main with commit f4fb868 Oct 19, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants