WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

idle_done() Hangs When Network Connection Severed #449

@TheConcolor

Description

@TheConcolor

While trying to find a good way to detect when there is no network connection while in a idle_check() loop, I discovered that if the network connection to the IMAP server is severed after idle() has been called, a call to idle_close() just hangs unless the network connection is restored.

with IMAPClient(host) as server:
    server.login(address, password)
    
    select = server.select_folder("INBOX", readonly=True)
    
    while True:

        i = 0

        print("IDLE starting...")
        server.idle()
        print("IDLE started")

        # Reset IDLE state every 30 seconds to ensure IMAP server connection exists
        while i < 6:
            responses = server.idle_check(timeout=5)
            print("Server sent:", responses if responses else "nothing")
            i += 1
        
        print("Stopping IDLE...")
        server.idle_done()
        print("IDLE stopped")

The purpose of stopping the IDLE state and restarting it every 30 seconds is to ensure a connection to the IMAP server still exists since idle_check() does not detect a connection loss.

Steps to Reproduce

  1. Connect to IMAP server and call idle()
  2. Disable network connection on client (I did this by disabling my wired NIC in NetworkManager)
  3. Code hangs at server.idle_done() while no network connection

Code Output

IDLE starting...
IDLE started
Server sent: nothing
Server sent: nothing
Server sent: nothing      # NIC disbled at this point
Server sent: nothing
Server sent: nothing
Server sent: nothing
Stopping IDLE...          # Code hangs here unless network connection restored

My Setup

  • Linux Mint 20
  • Python v3.8.10
  • IMAPClient v2.2.0 (installed via pip)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions