Skip to content

Commit

Permalink
Make releaseconnection a NOOP when conn is None
Browse files Browse the repository at this point in the history
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 <Sebastian@SSpaeth.de>
  • Loading branch information
spaetz committed Nov 2, 2011
1 parent 8b3ed8b commit 3aded16
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions offlineimap/imapserver.py
Expand Up @@ -113,6 +113,7 @@ def releaseconnection(self, connection, drop_conn=False):
: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
Expand Down

0 comments on commit 3aded16

Please sign in to comment.