From 6601c0d3a984795eb4074e75b27e558f6cb5b16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:26:21 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/textsource/texthook.py | 7 +++++-- build.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/LunaTranslator/LunaTranslator/textsource/texthook.py b/LunaTranslator/LunaTranslator/textsource/texthook.py index b59c9de0..e8f2e582 100644 --- a/LunaTranslator/LunaTranslator/textsource/texthook.py +++ b/LunaTranslator/LunaTranslator/textsource/texthook.py @@ -446,8 +446,11 @@ class texthook(basetext): _data, tms = self.newline_delaywait.get() collector.append(_data) - now = time.time() - time.sleep(min(now - tms, self.config["textthreaddelay"])/1000) + targettime = tms + self.config["textthreaddelay"] + sleepdur = targettime - time.time() + sleepdur = max(0, sleepdur) + sleepdur /= 1000 + time.sleep(sleepdur) if not self.newline_delaywait.empty(): continue diff --git a/build.py b/build.py index 9bdbc154..1c83336e 100644 --- a/build.py +++ b/build.py @@ -289,4 +289,5 @@ if __name__ == "__main__": subprocess.run(f"{py37Path} -m pip install -r requirements.txt") # 3.8之后会莫名其妙引用这个b东西,然后这个b东西会把一堆没用的东西导入进来 shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\test")) + shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\unittest")) subprocess.run(f"{py37Path} retrieval.py")