move loop to func

This commit is contained in:
Nexus 2023-03-16 23:27:03 +00:00
parent 5edfe83708
commit 44710e4c8c

View file

@ -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)