Repository navigation
Handle each failed job with its own queue's exception handler in run-worker - #2850
Open
sankalpsthakur wants to merge 2 commits into
Open
sankalpsthakur wants to merge 2 commits into
sankalpsthakur wants to merge 2 commits into
Conversation
…worker run-worker looked up the exception handler with the whole --queue option, so a worker on "scheduling|forecasting", as the hosting docs set it up, used the generic fallback handler for every job. Failed scheduling jobs lost their traceback in the worker log, and failed forecasting jobs were not counted in their meta. Give the worker one handler that passes each job on to the handler of the queue the job came from (job.origin), as run-job already does since FlexMeasures#2480. Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Documentation build overview
4 files changed± changelog.html± genindex.html± _autosummary/flexmeasures.cli.jobs.html± api/v3_0.html |
BelhsanHmida
approved these changes
Nov 9, 2026
BelhsanHmida
left a comment
Contributor
There was a problem hiding this comment.
Looks good, thanks for the fix! Just the changelog wording.
|
|
||
| * Hovering anywhere over a session in the Charge Points chart shows its tooltip again, listing all of the session's timestamps, as it did before the move to ECharts, without highlighting another charger's session; also, a chart's tooltip no longer shows a point from a neighbouring subplot [see `PR #2829 <https://www.github.com/FlexMeasures/flexmeasures/pull/2829>`_] | ||
|
|
||
| * Handle each failed job of a worker on several queues, such as one started with ``flexmeasures jobs run-worker --queue "scheduling|forecasting"``, with the exception handler of the job's own queue, so a failed scheduling job shows its traceback in the worker log [see `PR #2850 <https://www.github.com/FlexMeasures/flexmeasures/pull/2850>`_] |
Contributor
There was a problem hiding this comment.
RQ already logs the full traceback before any handler runs, so the traceback isn't what this fixes. The gain is on the forecasting side:
Suggested change
| * Handle each failed job of a worker on several queues, such as one started with ``flexmeasures jobs run-worker --queue "scheduling|forecasting"``, with the exception handler of the job's own queue, so a failed scheduling job shows its traceback in the worker log [see `PR #2850 <https://www.github.com/FlexMeasures/flexmeasures/pull/2850>`_] | |
| * Handle each failed job of a worker on several queues, such as one started with ``flexmeasures jobs run-worker --queue "scheduling|forecasting"``, with the exception handler of the job's own queue, so a failed forecasting job counts its failures in its meta and, if an automation created it, is recorded as failed in the automation run [see `PR #2850 <https://www.github.com/FlexMeasures/flexmeasures/pull/2850>`_] |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
flexmeasures jobs run-workerlooked up the exception handler with the whole--queueoption. A worker started on several queues, asdocumentation/host/installation.rstsets it up (--queue "scheduling|forecasting|ingestion|reporting"), therefore got the generic fallback handler for every job: a failed scheduling job lost its traceback in the worker log, and a failed forecasting job was not counted in its meta.handle_exception_by_queue, which passes each failed job on to the handler of the queue the job came from (job.origin), asrun-jobalready does since Run a job once, on its own queue, in flexmeasures jobs run-job #2480. It returns the inner handler's result, because RQ stops calling further handlers when one returnsFalse.documentation/changelog.rstLook & Feel
No visible change, apart from what the worker logs for a failed job.
How to test
test_run_worker_handles_a_job_with_the_handler_of_its_own_queuerunsrun-worker --queue "scheduling|forecasting"with an in-process burst worker on a failing forecasting job, and checks that the forecasting handler counted the failure in the job's meta. Onmainthe generic handler runs instead, which stores only the exception summary, so the assertion fails. The forecasting queue comes second in the option, so giving every job the first queue's handler would fail it too.test_handle_exception_by_queue_falls_back_and_passes_on_the_resultchecks that a job goes to its own queue's handler, that a queue without one falls back to the generic handler, and that aFalsefrom the handler reaches RQ.I could not run the tests myself: the suite needs a Postgres database, which I don't run locally, and Actions are disabled on my fork, so the CI of this PR is their first run. black 26.3.1 and mypy 2.3.1 (with the flags of the
type-checktask) pass on the two changed files, and flake8 7.1.1 with the repo's.flake8reports nothing on the changed lines.Further Improvements
None planned.
Related Items
Fixes #2526. The
run-jobpart of the issue was already fixed by #2480, so this PR only changesrun-worker.AI/LLM disclosure
Sign-off