From 8c1a668d9c32f98eea02734bbbc5f827fdb8ef78 Mon Sep 17 00:00:00 2001 From: "panxuchen.pxc" Date: Mon, 9 Sep 2024 20:33:18 +0800 Subject: [PATCH] fix redis pool --- src/agentscope/server/async_result_pool.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/agentscope/server/async_result_pool.py b/src/agentscope/server/async_result_pool.py index 5ff0f37a4..ff1121a29 100644 --- a/src/agentscope/server/async_result_pool.py +++ b/src/agentscope/server/async_result_pool.py @@ -118,10 +118,8 @@ def prepare(self) -> int: return self._get_object_id() def set(self, key: int, value: bytes) -> None: - pipe = self.pool.pipeline() - pipe.set(key, value, ex=self.max_timeout) - pipe.rpush(RedisPool.TASK_QUEUE_PREFIX + str(key), key) - pipe.execute() + self.pool.set(key, value, ex=self.max_timeout) + self.pool.rpush(RedisPool.TASK_QUEUE_PREFIX + str(key), key) def get(self, key: int) -> bytes: result = self.pool.get(key) @@ -132,6 +130,7 @@ def get(self, key: int) -> bytes: keys=RedisPool.TASK_QUEUE_PREFIX + str(key), timeout=self.max_timeout, ) + self.pool.rpush(RedisPool.TASK_QUEUE_PREFIX + str(key), key) if keys is None: raise ValueError( f"Waiting timeout for async result of task[{key}]",