email: timeout na IMAP konekcijama (zaglavljena veza blokirala kanal od 26.10.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
idriz
2026-11-14 16:16:52 +01:00
parent f2c7253672
commit 83469f98cf

View File

@@ -138,7 +138,7 @@ def fetch_unseen() -> list[Dolazna]:
""" """
user, pw = credentials() user, pw = credentials()
out = [] out = []
with imaplib.IMAP4_SSL(HOST, IMAP_PORT, ssl_context=ssl.create_default_context()) as imap: with imaplib.IMAP4_SSL(HOST, IMAP_PORT, ssl_context=ssl.create_default_context(), timeout=60) as imap:
imap.login(user, pw) imap.login(user, pw)
imap.select("INBOX") imap.select("INBOX")
typ, data = imap.uid("SEARCH", None, "UNSEEN") typ, data = imap.uid("SEARCH", None, "UNSEEN")
@@ -190,7 +190,7 @@ def send(msg: EmailMessage) -> None:
smtp.send_message(msg) smtp.send_message(msg)
# kopija u "Sent" (nije kritično ako ne uspije) # kopija u "Sent" (nije kritično ako ne uspije)
try: try:
with imaplib.IMAP4_SSL(HOST, IMAP_PORT, ssl_context=ssl.create_default_context()) as imap: with imaplib.IMAP4_SSL(HOST, IMAP_PORT, ssl_context=ssl.create_default_context(), timeout=60) as imap:
imap.login(user, pw) imap.login(user, pw)
imap.append("Sent", "(\\Seen)", None, msg.as_bytes()) imap.append("Sent", "(\\Seen)", None, msg.as_bytes())
imap.logout() imap.logout()