]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
imaplib: elaborate in idle context manager comment
authorForest <forestix@nom.one>
Sun, 22 Sep 2024 20:33:14 +0000 (13:33 -0700)
committerForest <forestix@nom.one>
Sun, 22 Sep 2024 20:33:14 +0000 (13:33 -0700)
Lib/imaplib.py

index 25c3e017fe4be254e9e56a02fd2d2735638731d2..718c53483e3becd4589060efc740c68c2b7d7d24 100644 (file)
@@ -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}')