From: Forest Date: Sun, 22 Sep 2024 20:33:14 +0000 (-0700) Subject: imaplib: elaborate in idle context manager comment X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=882bf2c85e027cecd2d5ff6cf1c27f33b0b80e72;p=thirdparty%2FPython%2Fcpython.git imaplib: elaborate in idle context manager comment --- diff --git a/Lib/imaplib.py b/Lib/imaplib.py index 25c3e017fe4b..718c53483e3b 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -1416,8 +1416,13 @@ class _Idler: imap._idle_capture = True self._tag = imap._command('IDLE') - # Process responses until the server requests continuation - while resp := imap._get_response(): # Returns None on continuation + # As with any command, the server is allowed to send us unrelated, + # untagged responses before acting on IDLE. These lines will be + # returned by _get_response(). When the server is ready, it will + # send an IDLE continuation request, indicated by _get_response() + # returning None. We therefore process responses in a loop until + # this occurs. + while resp := imap._get_response(): if imap.tagged_commands[self._tag]: raise imap.abort(f'unexpected status response: {resp}')