mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-10-19 09:48:11 +00:00
Merge pull request #313 from nathanthorpe/imap_watch_fix
fix callback on IMAPConnection
This commit is contained in:
1 file changed
+8
-1
@@ -53,6 +53,13 @@ class IMAPConnection(MailboxConnection):
|
|||||||
Use an IDLE IMAP connection to parse incoming emails,
|
Use an IDLE IMAP connection to parse incoming emails,
|
||||||
and pass the results to a callback function
|
and pass the results to a callback function
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# IDLE callback sends IMAPClient object,
|
||||||
|
# send back the imap connection object instead
|
||||||
|
def idle_callback_wrapper(client: IMAPClient):
|
||||||
|
self._client = client
|
||||||
|
check_callback(self)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
IMAPClient(host=self._client.host,
|
IMAPClient(host=self._client.host,
|
||||||
@@ -61,7 +68,7 @@ class IMAPConnection(MailboxConnection):
|
|||||||
port=self._client.port,
|
port=self._client.port,
|
||||||
ssl=self._client.ssl,
|
ssl=self._client.ssl,
|
||||||
verify=self._verify,
|
verify=self._verify,
|
||||||
idle_callback=check_callback,
|
idle_callback=idle_callback_wrapper,
|
||||||
idle_timeout=check_timeout)
|
idle_timeout=check_timeout)
|
||||||
except (timeout, IMAPClientError):
|
except (timeout, IMAPClientError):
|
||||||
logger.warning("IMAP connection timeout. Reconnecting...")
|
logger.warning("IMAP connection timeout. Reconnecting...")
|
||||||
|
|||||||
Reference in new issue
Block a user