mirror of
https://github.com/chatmail/core.git
synced 2026-08-13 12:46:08 +03:00
test: avoid another source of random failures with direct_imap failing to connect on first try
also core src/imap.rs retries connecting (2s with backoff) but direct_imap is only used in (CI) tests and we can just keep trying every second until pytest timeout hits.
This commit is contained in:
@@ -7,6 +7,7 @@ import imaplib
|
||||
import io
|
||||
import pathlib
|
||||
import ssl
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from typing import List, TYPE_CHECKING
|
||||
|
||||
@@ -42,10 +43,14 @@ class DirectImap:
|
||||
host = user.rsplit("@")[-1]
|
||||
pw = self.account.get_config("mail_pw")
|
||||
|
||||
self.conn = MailBox(host, port, ssl_context=ssl.create_default_context())
|
||||
self.conn.login(user, pw)
|
||||
|
||||
self.select_folder("INBOX")
|
||||
while True:
|
||||
try:
|
||||
self.conn = MailBox(host, port, ssl_context=ssl.create_default_context())
|
||||
self.conn.login(user, pw)
|
||||
self.select_folder("INBOX")
|
||||
return
|
||||
except (OSError, ssl.SSLError, imaplib.IMAP4.error):
|
||||
time.sleep(1)
|
||||
|
||||
def shutdown(self):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user