Skip to content

Commit

Permalink
supress errors during close
Browse files Browse the repository at this point in the history
  • Loading branch information
akshetpandey committed Feb 28, 2024
1 parent fbaa378 commit f91b4ee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions django_mailbox/transports/imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ def connect(self, username, password):
self.server.select()

def close(self):
self.server.close()
self.server.logout()
try:
self.server.close()
self.server.logout()
except (imaplib.IMAP4.error, OSError) as e:
logger.warning(f'Failed to close IMAP connection, ignoring: {e}')
pass

def _get_all_message_ids(self):
# Fetch all the message uids
Expand Down

0 comments on commit f91b4ee

Please sign in to comment.