diff --git a/LunaTranslator/LunaTranslator/translator/baiduqianfan.py b/LunaTranslator/LunaTranslator/translator/baiduqianfan.py index 0d89c294..cf73b0c5 100644 --- a/LunaTranslator/LunaTranslator/translator/baiduqianfan.py +++ b/LunaTranslator/LunaTranslator/translator/baiduqianfan.py @@ -65,7 +65,8 @@ class TS(basetrans): msg = json_data["result"].replace("\n\n", "\n").strip() yield msg message += msg - + except GeneratorExit: + return except: print_exc() raise Exception(response_data) diff --git a/LunaTranslator/LunaTranslator/translator/basetranslator.py b/LunaTranslator/LunaTranslator/translator/basetranslator.py index 17993f67..9dcc727d 100644 --- a/LunaTranslator/LunaTranslator/translator/basetranslator.py +++ b/LunaTranslator/LunaTranslator/translator/basetranslator.py @@ -384,6 +384,9 @@ class basetrans(commonbase): __callback(res, 0) if all([_ is not None for _ in collectiterres]): self.cachesetatend(contentsolved, "".join(collectiterres)) + + except GeneratorExit: + pass except Exception as e: if self.using and globalconfig["showtranexception"]: if isinstance(e, ArgsEmptyExc): diff --git a/LunaTranslator/LunaTranslator/translator/claude.py b/LunaTranslator/LunaTranslator/translator/claude.py index 14edb94a..fe0f6404 100644 --- a/LunaTranslator/LunaTranslator/translator/claude.py +++ b/LunaTranslator/LunaTranslator/translator/claude.py @@ -118,6 +118,8 @@ class TS(basetrans): msg = json_data["content_block"]["text"] yield msg message += msg + except GeneratorExit: + return except: print_exc() raise Exception(response_data) diff --git a/LunaTranslator/LunaTranslator/translator/cohere.py b/LunaTranslator/LunaTranslator/translator/cohere.py index ed786f5c..54d9c099 100644 --- a/LunaTranslator/LunaTranslator/translator/cohere.py +++ b/LunaTranslator/LunaTranslator/translator/cohere.py @@ -155,6 +155,8 @@ class TS(basetrans): elif t == "stream-end": break + except GeneratorExit: + return except: print_exc() raise Exception(response_data) diff --git a/LunaTranslator/LunaTranslator/translator/gptcommon.py b/LunaTranslator/LunaTranslator/translator/gptcommon.py index 6c7f3d3b..bb54aa42 100644 --- a/LunaTranslator/LunaTranslator/translator/gptcommon.py +++ b/LunaTranslator/LunaTranslator/translator/gptcommon.py @@ -96,7 +96,9 @@ class gptcommon(basetrans): continue yield msg message += msg - + + except GeneratorExit: + return except: print_exc() raise Exception(response_data)