From 2ae6cdb69d8d0f75a830ca3c36d108bf43577583 Mon Sep 17 00:00:00 2001 From: "panxuchen.pxc" Date: Tue, 10 Sep 2024 10:24:40 +0800 Subject: [PATCH] add fix --- src/agentscope/memory/temporary_memory.py | 3 +-- src/agentscope/server/async_result_pool.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/agentscope/memory/temporary_memory.py b/src/agentscope/memory/temporary_memory.py index 0753ebfd7..0b68cb802 100644 --- a/src/agentscope/memory/temporary_memory.py +++ b/src/agentscope/memory/temporary_memory.py @@ -73,13 +73,12 @@ def add( else: record_memories = memories + # FIXME: a single message may be inserted multiple times # Assert the message types memories_idx = set(_.id for _ in self._content if hasattr(_, "id")) for memory_unit in record_memories: # in case this is a PlaceholderMessage, try to update # the values first - # TODO: Unify PlaceholderMessage and Msg into one class to avoid - # type error if isinstance(memory_unit, AsyncResult): memory_unit = memory_unit.result() diff --git a/src/agentscope/server/async_result_pool.py b/src/agentscope/server/async_result_pool.py index ff1121a29..992a5f5e6 100644 --- a/src/agentscope/server/async_result_pool.py +++ b/src/agentscope/server/async_result_pool.py @@ -118,8 +118,10 @@ def prepare(self) -> int: return self._get_object_id() def set(self, key: int, value: bytes) -> None: + qkey = RedisPool.TASK_QUEUE_PREFIX + str(key) self.pool.set(key, value, ex=self.max_timeout) - self.pool.rpush(RedisPool.TASK_QUEUE_PREFIX + str(key), key) + self.pool.rpush(qkey, key) + self.pool.expire(qkey, self.max_timeout) def get(self, key: int) -> bytes: result = self.pool.get(key)