Skip to content

Commit 07b21f2

Browse files
committed
docs
1 parent d458f7b commit 07b21f2

File tree

1 file changed

+13
-8
lines changed
  • services/storage/src/simcore_service_storage/modules/celery

1 file changed

+13
-8
lines changed

services/storage/src/simcore_service_storage/modules/celery/client.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,35 @@ def __init__(self, celery_app: Celery):
6161
def send_task(
6262
self, task_name: str, *, task_context: TaskContext, **task_params
6363
) -> TaskUUID:
64-
task_uuid = uuid4()
65-
task_id = _build_task_id(task_context, task_uuid)
6664
with log_context(
6765
_logger,
6866
logging.DEBUG,
69-
msg=f"Submitting task {task_name}: {task_id=} {task_params=}",
67+
msg=f"Submit {task_name=}: {task_context=} {task_params=}",
7068
):
69+
task_uuid = uuid4()
70+
task_id = _build_task_id(task_context, task_uuid)
7171
self._celery_app.send_task(task_name, task_id=task_id, kwargs=task_params)
7272
return task_uuid
7373

7474
@staticmethod
7575
@make_async()
7676
def abort_task(task_context: TaskContext, task_uuid: TaskUUID) -> None:
77-
task_id = _build_task_id(task_context, task_uuid)
78-
_logger.info("Aborting task %s", task_id)
79-
AbortableAsyncResult(task_id).abort()
77+
with log_context(
78+
_logger,
79+
logging.DEBUG,
80+
msg=f"Abort task {task_uuid=}: {task_context=}",
81+
):
82+
task_id = _build_task_id(task_context, task_uuid)
83+
AbortableAsyncResult(task_id).abort()
8084

8185
@make_async()
8286
def get_task_result(self, task_context: TaskContext, task_uuid: TaskUUID) -> Any:
83-
task_id = _build_task_id(task_context, task_uuid)
8487
with log_context(
8588
_logger,
8689
logging.DEBUG,
87-
msg=f"Getting task {task_id=} result",
90+
msg=f"Get task {task_uuid=}: {task_context=} result",
8891
):
92+
task_id = _build_task_id(task_context, task_uuid)
8993
return self._celery_app.AsyncResult(task_id).result
9094

9195
def _get_progress_report(
@@ -133,6 +137,7 @@ def _get_completed_task_uuids(self, task_context: TaskContext) -> set[TaskUUID]:
133137
for key in keys
134138
}
135139
if hasattr(backend_client, "cache"):
140+
# NOTE: backend used in testing. It is a dict-like object
136141
found_keys = set()
137142
for key in backend_client.cache:
138143
str_key = key.decode(_CELERY_TASK_ID_KEY_ENCODING)

0 commit comments

Comments
 (0)