Skip to content

Expose details in worker timeout exceptions #9092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nocnokneo
Copy link
Contributor

@nocnokneo nocnokneo commented Jun 11, 2025

in a structured way so that calling code can have more precise logic about how to handle the error

Closes #xxxx

  • Tests added / passed
    • Some existing tests failed but all seem unrelated to this change
  • Passes pre-commit run --all-files

so that calling code can have more precise logic about how to handle the error
@nocnokneo nocnokneo force-pushed the custom-worker-timeout-exception branch from c3ee5de to 097ed4a Compare June 11, 2025 20:22
Copy link
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    27 files  ±0      27 suites  ±0   11h 14m 31s ⏱️ + 6m 51s
 4 115 tests ±0   3 999 ✅  - 2    111 💤 ±0   4 ❌ +1  1 🔥 +1 
51 596 runs  +1  49 301 ✅  - 7  2 284 💤 ±0  10 ❌ +7  1 🔥 +1 

For more details on these failures and errors, see this check.

Results for commit 097ed4a. ± Comparison against base commit 9c8cd91.

Copy link
Member

@jacobtomlinson jacobtomlinson left a comment

Choose a reason for hiding this comment

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

Overall this seems useful thanks!

Comment on lines +28 to +31
@property
def available_workers(self) -> int:
"""Number of workers that are available."""
return self.args[0]
Copy link
Member

Choose a reason for hiding this comment

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

I've not seen exceptions implemented this way before with properties pointing to arg indices. There's a code smell here I can't quite put my finger on, it feels brittle.

Why not set the attributes explicitly during the __init__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hah, I totally agree! I had originally set the attributes in __init__ but noticed that other custom exceptions in this project were following this (odd) pattern so just went with it for consistency. Happy to revert back to my original approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One example of the existing pattern:

class KilledWorker(Exception):

@nocnokneo nocnokneo marked this pull request as ready for review June 12, 2025 15:23
@nocnokneo nocnokneo requested a review from fjetter as a code owner June 12, 2025 15:23
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.

2 participants