From 473bcd0e3e7c545c36159356ceacb809836c963d Mon Sep 17 00:00:00 2001 From: VG Date: Thu, 19 May 2016 12:55:05 +0200 Subject: Remove catchall rerun connect only if disconnected Disconnections (socket/ssl errors) should be catched to retry connections. Other exceptions should not be handled, instead hooks are encouraged to fix their codes. --- climl/imap.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/climl/imap.py b/climl/imap.py index 6bdcb04..0de15d8 100644 --- a/climl/imap.py +++ b/climl/imap.py @@ -3,7 +3,7 @@ import subprocess import confparser import imapclient import contextlib -import backports.ssl +import backports.ssl as ssl import socket import time @@ -145,7 +145,10 @@ def main(callback=None): for oneid in idlist: print('calling callback...') callback('mail: ' + str(oneid)) - except (socket.error, socket.timeout, backports.ssl.SSLError): + except (socket.error, + socket.timeout, + ssl.SSLError, + ssl.CertificateError): print('socket/ssl error, retrying in 10s...') try: time.sleep(10) # wait between retries @@ -153,10 +156,4 @@ def main(callback=None): break except KeyboardInterrupt: break - except Exception as e: - print('Unhandled exception during connection: ', e) - try: - time.sleep(10) # wait between retries - except KeyboardInterrupt: - break print('end of connection') -- cgit v1.2.3