From 3aded16ed4de691d79581f3b27d4da8dd9bc684d Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Wed, 2 Nov 2011 10:34:45 +0100 Subject: [PATCH] Make releaseconnection a NOOP when conn is None During cleanup we often call releaseconnection in a finally: block. But in cases of error, we might have dropped the connection earlier already and set it to "None". In this case don't fail releaseconnection() but make it a NOOP. Signed-off-by: Sebastian Spaeth --- offlineimap/imapserver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index ef54e31..b7f062d 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -113,6 +113,7 @@ class IMAPServer: :param drop_conn: If True, the connection will be released and not be reused. This can be used to indicate broken connections.""" + if connection is None: return #noop on bad connection self.connectionlock.acquire() self.assignedconnections.remove(connection) # Don't reuse broken connections