Skip to content

Fix ASGI SIGTERM handler to chain to host server and skip lifespan scope - #240

Open
sharosoo wants to merge 1 commit into
restatedev:mainfrom
sharosoo:fix/restate-sdk-python-sigterm-fix
Open

sharosoo wants to merge 1 commit into
restatedev:mainfrom
sharosoo:fix/restate-sdk-python-sigterm-fix

Conversation

@sharosoo

Copy link
Copy Markdown

Fixes #236.

Changes

  • Reject lifespan and non-http scopes before installing the SIGTERM handler so lifespan probes do not displace the host server's signal handler.
  • Capture the existing SIGTERM handler from both getattr(loop, '_signal_handlers', {}).get(signal.SIGTERM) (used by loop.add_signal_handler hosts such as Hypercorn) and signal.getsignal(signal.SIGTERM) (used by signal.signal hosts such as Uvicorn) before registering _on_sigterm.
  • Chain to the captured handler from _on_sigterm after notifying active ReceiveChannel instances.
  • Add unit tests in tests/server.py covering loop.add_signal_handler chaining (including callback arguments), signal.signal chaining, and lifespan / non-http scopes.

Related: #226.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sharosoo

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

ASGI app SIGTERM handler silently replaces the hosting server's handler

1 participant