Hi, I have the following run_status_sensor to catc...
# ask-community
t
Hi, I have the following run_status_sensor to catch all job that have been cancelled
Copy code
@run_status_sensor(run_status=DagsterRunStatus.CANCELED)
def job_canceled_sensor(context: RunStatusSensorContext):
    prometheus = PrometheusClient()
    status = 'canceled'
    logger = get_dagster_logger(name='JOB_STATUS_SENSOR')
    <http://logger.info|logger.info>(f"job_canceled_sensor - {context.dagster_run.job_name} - {status}")
    prometheus.change_job_state(context.dagster_run.job_name, status)
    prometheus.pushadd_to_gateway(job_name=context.dagster_run.job_name)
But then when I terminate the job via the UI, the job state is CANCELED but the sensor is not triggered. Am I doing something wrong?
p
It doesn’t look like you’re doing anything wrong in the code snippet…. What are you seeing? Is the sensor is turned on and you’re just seeing ticks being skipped?
t
Thanks for responding. I played a bit more with trying to narrow down the problem. The sensor is turned on I have a job with a retry logic that has an op that sleep and I'm interrupting it while sleeping. Then I get the following exception and nothing else beside the fact that the job is in a
Canceled
state without the sensor being called