Skip to content

fix(sdks/python): propagate worker registration failures - #5341

Merged
mrkaye97 merged 3 commits into
hatchet-dev:mainfrom
satya-sudo:fix/python-worker-registration-failure
Oct 29, 2026
Merged

mrkaye97 merged 3 commits into
hatchet-dev:mainfrom
satya-sudo:fix/python-worker-registration-failure

Conversation

@satya-sudo

@satya-sudo satya-sudo commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

When a Python worker's registration RPC failed, listener cleanup could raise an AttributeError for an uninitialized task. The parent then shut down with exit code 0, leaving the worker stopped under an on-failure restart policy.

Initialize the optional blocked_main_loop task, propagate registration errors, and close the health server if listener startup fails. Record unexpected listener termination in the parent so Worker.start() raises after graceful cleanup instead of reporting success. Intentional task-limit shutdown continues to exit successfully.

Adds regression coverage, bumps the Python SDK to 1.43.3, and updates the SDK and generated documentation changelogs.

Closes #5280

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Test changes (add, refactor, improve or change a test)

Checklist

  • Documented (where applicable)
  • Added to CHANGELOG (where applicable)

Testing

  • Python 3.12: python -m pytest tests/unit/test_worker_registration_failure.py tests/unit/test_shutdown_ordering.py -q -o log_cli=false — 18 passed.
  • Covers INTERNAL, UNAVAILABLE, and UNAUTHENTICATED registration errors; health-server cleanup; a real spawned listener subprocess exiting with the original error; parent failure propagation for unexpected listener exits; and successful task-limit shutdown.
  • Existing shutdown tests verify event draining and heartbeat ordering.
  • Black 26.10.1 formatting check passed for the three changed Python files.
  • git diff --check passed.
🤖 AI Disclosure
  • I acknowledge that an LLM was used in the creation of this Pull Request, in accordance with Hatchet's AI_POLICY.md.
  • Details: OpenAI Codex assisted with investigation, implementing the fix and regression tests, updating release notes, running checks, and preparing this PR.

Propagate registration RPC errors and close the health server when listener
startup fails. Record unexpected listener termination so Worker.start raises
after graceful cleanup instead of exiting successfully.

Add regression coverage, bump the Python SDK to 1.43.1, and sync the
changelog documentation.

Refs hatchet-dev#5280
@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

@satya-sudo is attempting to deploy a commit to the Hatchet Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added documentation Improvements or additions to documentation sdk-py Related to the Python sdk labels Oct 27, 2026
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The Python SDK now reports worker registration failures and unexpected listener exits instead of returning success.

  • The listener child now exits with its startup failure.
  • Worker.start now reports unexpected listener exits after graceful shutdown.

Review was based on code inspection; tests were not run.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into fix/python-work..." · Reviewed by Greptile

@mrkaye97
mrkaye97 self-requested a review October 28, 2026 13:01

@mrkaye97 mrkaye97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me, thanks for the fix!

@mrkaye97
mrkaye97 merged commit bedfda2 into hatchet-dev:main Oct 29, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation sdk-py Related to the Python sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Python SDK: worker exits with code 0 and AttributeError when Register fails

2 participants