From d1ec6f487aaf25ce13f13d2d814023678e1d2bed Mon Sep 17 00:00:00 2001 From: morvanzhou Date: Thu, 19 Sep 2024 20:54:37 +0800 Subject: [PATCH] feat(app): add timeout; fix ai extent not counted for es --- src/retk/core/node/node.py | 2 +- src/retk/core/utils/cos.py | 3 ++- src/retk/models/client.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/retk/core/node/node.py b/src/retk/core/node/node.py index 20cff25..3bee96f 100644 --- a/src/retk/core/node/node.py +++ b/src/retk/core/node/node.py @@ -41,7 +41,7 @@ async def post( if from_nid != "": from_nids.append(from_nid) res = await db_ops.node_add_to_set(from_nid, "toNodeIds", nid) - if res.modified_count != 1: + if not res.acknowledged: return None, const.CodeEnum.OPERATION_FAILED new_to_node_ids = [] diff --git a/src/retk/core/utils/cos.py b/src/retk/core/utils/cos.py index 45f5125..73e06a0 100644 --- a/src/retk/core/utils/cos.py +++ b/src/retk/core/utils/cos.py @@ -107,6 +107,7 @@ async def async_put(self, file: BinaryIO, uid: str, filename: str) -> bool: url=f"https://{self.domain}/{key}", headers=self.get_auth_headers("put", key), content=file.read(), + timeout=60, ) if resp.status_code != 200: logger.error(f"put_cos_object | error: {resp.text}") @@ -117,7 +118,7 @@ async def async_put(self, file: BinaryIO, uid: str, filename: str) -> bool: httpx.ReadTimeout, httpx.HTTPError ) as e: - logger.error(f"put_cos_object | error: {e}") + logger.error(f"put_cos_object | error: {str(e)}") return False return True diff --git a/src/retk/models/client.py b/src/retk/models/client.py index 77e6e7b..a3ecd69 100644 --- a/src/retk/models/client.py +++ b/src/retk/models/client.py @@ -363,7 +363,7 @@ async def try_restore_search(self): return logger.critical( f"restore search index count: {count_search}, mongo count: {count_mongo}." - f" They are not equal, tring to restore search index") + f" They are not equal, trying to restore search index") await self.search.drop() await self.search.init()