You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the IMAPClient library to implement an email notifier using the IMAP IDLE command to wait for incoming email notifications. However, the IDLE command seems to be skipping some email notifications when multiple emails are sent in quick succession.
For example, when I send 3 emails in a row, the code only receives a notification for the first one. After the first notification, it seems to miss the others, even though they arrive in the inbox.
Here’s the relevant code snippet:
IDLE_TIMEOUT=15*60defemail_notifier():
withIMAPClient(host=HOST) asclient:
client.login(USERNAME, PASSWORD)
client.select_folder(MAILBOX)
whileTrue:
try:
# Wait for up to {IDLE_TIMEOUT} seconds for an IDLE responseclient.idle()
responses=client.idle_check(timeout=IDLE_TIMEOUT)
ifnotresponses:
print("Server sent: nothing")
else:
print("Server sent:", responses)
new_emails_orders= []
forresponseinresponses:
ifresponse[1].decode() =="EXISTS":
new_emails_orders.append(response[0])
ifnew_emails_orders:
task_queue.put(new_emails_orders)
client.idle_done()
exceptKeyboardInterrupt:
print("Shutting down.")
breakclient.idle_done()
print("\nIDLE mode done")
client.logout()
What I Tried:
Adjusted the IDLE_TIMEOUT value to be as short as 2 seconds and as long as 15 minutes, but the issue persists.
When I do not renew the idle command, it works fine, but based on my research, the IDLE command will automatically close after 30 minutes of inactivity, and it doesn't handle network exceptions well.
Is there a better way to handle the IDLE command to ensure it's always active, doesn't miss any notifications, and properly handles network exceptions?
The text was updated successfully, but these errors were encountered:
I am using the IMAPClient library to implement an email notifier using the IMAP IDLE command to wait for incoming email notifications. However, the IDLE command seems to be skipping some email notifications when multiple emails are sent in quick succession.
For example, when I send 3 emails in a row, the code only receives a notification for the first one. After the first notification, it seems to miss the others, even though they arrive in the inbox.
Here’s the relevant code snippet:
What I Tried:
Environment
IMAPClient version: ^3.0.1
Python version: 3.11.4
OS: Windows 11
IMAP Server: imap.gmail.com
Is there a better way to handle the IDLE command to ensure it's always active, doesn't miss any notifications, and properly handles network exceptions?
The text was updated successfully, but these errors were encountered: