add timeout for reading mails

This commit is contained in:
2026-04-04 11:28:49 +02:00
parent 1fa29ebd37
commit c84266f8fd
2 changed files with 20 additions and 9 deletions
+6 -1
View File
@@ -220,12 +220,17 @@ class ProxyIMAPClient(IMAPClient):
def _create_IMAP4(self):
"""Remplace la méthode d'IMAPClient pour injecter ProxyIMAP4_TLS."""
if self.ssl:
# self._timeout peut être un float (secondes) ou un objet avec
# un attribut 'connect' (ex : urllib3 Timeout). On gère les deux.
_timeout = self._timeout
if _timeout is not None and not isinstance(_timeout, (int, float)):
_timeout = getattr(_timeout, "connect", None)
return ProxyIMAP4_TLS(
host=self.host,
port=self.port,
ssl_context=self.ssl_context,
proxy=self._proxy,
timeout=getattr(self._timeout, "connect", None),
timeout=_timeout,
)
# Connexion non-SSL à travers le proxy (rare, mais supporté)
# On monkey-patch juste la connexion TCP