From 44710e4c8c3672d9c97c9641b4e981d11192f967 Mon Sep 17 00:00:00 2001 From: nex Date: Thu, 16 Mar 2023 23:27:03 +0000 Subject: [PATCH] move loop to func --- cogs/other.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cogs/other.py b/cogs/other.py index 5987ae8..8074ca9 100644 --- a/cogs/other.py +++ b/cogs/other.py @@ -840,7 +840,19 @@ class OtherCog(commands.Cog): engine.save_to_file(text, target_fn) engine.runAndWait() last_3_sizes = [-3, -2, -1] - while not os.path.exists(target_fn) or not all(x == os.stat(target_fn).st_size for x in last_3_sizes): + + def should_loop(): + if not os.path.exists(target_fn): + return True + + stat = os.stat(target_fn) + for _result in last_3_sizes: + if stat.st_size != _result: + return True + + return False + + while should_loop(): last_3_sizes.pop(-1) last_3_sizes.append(os.stat(target_fn).st_size) sleep(3)