Skip to content

Commit 4af263a

Browse files
committed
@pcrespov review: simplify
1 parent 013a74e commit 4af263a

File tree

1 file changed

+7
-13
lines changed
  • services/director-v2/src/simcore_service_director_v2/modules

1 file changed

+7
-13
lines changed

services/director-v2/src/simcore_service_director_v2/modules/dask_client.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,16 @@ async def _get_task_state(job_id: str) -> RunningState:
455455
timeout=_DASK_DEFAULT_TIMEOUT_S
456456
)
457457
assert isinstance(exception, Exception) # nosec
458-
458+
log_error_context = {
459+
"job_id": job_id,
460+
"dask-scheduler": self.backend.scheduler_id,
461+
}
459462
if isinstance(exception, TaskCancelledError):
460463
_logger.info(
461464
**create_troubleshootting_log_kwargs(
462465
f"Task {job_id} was aborted by user",
463466
error=exception,
464-
error_context={
465-
"job_id": job_id,
466-
"dask-scheduler": self.backend.scheduler_id,
467-
},
467+
error_context=log_error_context,
468468
)
469469
)
470470
return RunningState.ABORTED
@@ -473,10 +473,7 @@ async def _get_task_state(job_id: str) -> RunningState:
473473
**create_troubleshootting_log_kwargs(
474474
f"Task {job_id} completed with an error",
475475
error=exception,
476-
error_context={
477-
"job_id": job_id,
478-
"dask-scheduler": self.backend.scheduler_id,
479-
},
476+
error_context=log_error_context,
480477
)
481478
)
482479
return RunningState.FAILED
@@ -485,10 +482,7 @@ async def _get_task_state(job_id: str) -> RunningState:
485482
**create_troubleshootting_log_kwargs(
486483
f"Task {job_id} exception could not be retrieved due to timeout",
487484
error=exc,
488-
error_context={
489-
"job_id": job_id,
490-
"dask-scheduler": self.backend.scheduler_id,
491-
},
485+
error_context=log_error_context,
492486
tip="The dask-scheduler is probably under load, this should resolve itself later.",
493487
),
494488
)

0 commit comments

Comments
 (0)