Skip to content

Commit 85cdd6b

Browse files
author
Andrei Neagu
committed
repalced serializers
1 parent 41636d7 commit 85cdd6b

File tree

1 file changed

+5
-5
lines changed
  • packages/service-library/src/servicelib/long_running_tasks/_store

1 file changed

+5
-5
lines changed

packages/service-library/src/servicelib/long_running_tasks/_store/redis.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import json
21
from typing import Any, Final
32

43
import redis.asyncio as aioredis
4+
from common_library.json_serialization import json_dumps, json_loads
55
from pydantic import TypeAdapter
66
from settings_library.redis import RedisDatabase, RedisSettings
77

@@ -66,17 +66,17 @@ async def delete_task_data(self, task_id: TaskId) -> None:
6666
async def set_as_cancelled(
6767
self, task_id: TaskId, with_task_context: TaskContext | None
6868
) -> None:
69-
70-
value = None if with_task_context is None else json.dumps(with_task_context)
7169
await self.redis.hset(
72-
self._get_redis_hash_key(STORE_TYPE_CANCELLED_TASKS), task_id, value
70+
self._get_redis_hash_key(STORE_TYPE_CANCELLED_TASKS),
71+
task_id,
72+
json_dumps(with_task_context),
7373
)
7474

7575
async def get_cancelled(self) -> dict[TaskId, TaskContext | None]:
7676
result: dict[str, str | None] = await self.redis.hgetall(
7777
self._get_redis_hash_key(STORE_TYPE_CANCELLED_TASKS)
7878
)
7979
return {
80-
task_id: (json.loads(context) if context else None)
80+
task_id: (json_loads(context) if context else None)
8181
for task_id, context in result.items()
8282
}

0 commit comments

Comments
 (0)