Prevent an infinite loop

This commit is contained in:
Rodolphe Bréard 2023-04-30 17:08:22 +02:00
parent 8e75759a19
commit e33d7c26b7

View file

@ -163,8 +163,13 @@ def start_tests(test_dir, maildir, smtp_port):
nb_dkim_ok = 0
nb_dkim_total = 0
maildir_glob = f"{maildir.name}/Maildir/new/*"
nb_sleep = 0
while len(glob.glob(maildir_glob)) < nb_total:
time.sleep(1)
nb_sleep += 1
if nb_sleep > 6:
print("Some messages have not been received.", file=sys.stderr)
sys.exit(1)
time.sleep(nb_sleep)
for test_msg in glob.glob(maildir_glob):
nb_dkim_total += 1
nb_dkim_ok += test_dkim(test_msg)