Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94c02e8

Browse files
author
Forest
committed
imaplib: rename _Idler to Idler, update its docs
1 parent acbc4a1 commit 94c02e8

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

Doc/library/imaplib.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ An :class:`IMAP4` instance has the following methods:
310310

311311
.. method:: IMAP4.idle(dur=None)
312312

313-
Return an iterable context manager implementing the ``IDLE`` command
314-
as defined in :rfc:`2177`.
313+
Return an ``Idler``: an iterable context manager implementing the ``IDLE``
314+
command as defined in :rfc:`2177`.
315315

316316
The context manager sends the ``IDLE`` command when activated by the
317317
:keyword:`with` statement, produces IMAP untagged responses via the
@@ -346,7 +346,7 @@ An :class:`IMAP4` instance has the following methods:
346346
batch processing aid is provided by the context's ``burst()``
347347
:term:`generator`:
348348

349-
.. method:: idler.burst(interval=0.1)
349+
.. method:: Idler.burst(interval=0.1)
350350

351351
Yield a burst of responses no more than *interval* seconds apart.
352352

@@ -391,6 +391,13 @@ An :class:`IMAP4` instance has the following methods:
391391
not to use ``burst()`` with an :class:`IMAP4_stream` connection on
392392
Windows.
393393

394+
.. note::
395+
396+
Note: The ``Idler`` class name and structure are internal interfaces,
397+
subject to change. Calling code can rely on its context management,
398+
iteration, and public method to remain stable, but should not
399+
subclass, instantiate, or otherwise directly reference the class.
400+
394401

395402
.. method:: IMAP4.list([directory[, pattern]])
396403

Lib/imaplib.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def getquotaroot(self, mailbox):
649649

650650

651651
def idle(self, dur=None):
652-
"""Return an iterable context manager implementing the IDLE command
652+
"""Return an Idler: an iterable context manager for the IDLE command
653653
654654
:param dur: Maximum duration (in seconds) to keep idling,
655655
or None for no time limit.
@@ -681,8 +681,13 @@ def idle(self, dur=None):
681681
Assuming that's typical of IMAP servers, subtracting it from the 29
682682
minutes needed to avoid server inactivity timeouts would make 27
683683
minutes a sensible value for 'dur' in this situation.
684+
685+
Note: The Idler class name and structure are internal interfaces,
686+
subject to change. Calling code can rely on its context management,
687+
iteration, and public method to remain stable, but should not
688+
subclass, instantiate, or otherwise directly reference the class.
684689
"""
685-
return _Idler(self, dur)
690+
return Idler(self, dur)
686691

687692

688693
def list(self, directory='""', pattern='*'):
@@ -1384,13 +1389,24 @@ def print_log(self):
13841389
n -= 1
13851390

13861391

1387-
class _Idler:
1388-
# Iterable context manager: start IDLE & produce untagged responses
1389-
#
1390-
# This iterator produces (type, datum) tuples. They slightly differ
1391-
# from the tuples returned by IMAP4.response(): The second item in the
1392-
# tuple is a single datum, rather than a list of them, because only one
1393-
# untagged response is produced at a time.
1392+
class Idler:
1393+
"""Iterable context manager: start IDLE & produce untagged responses
1394+
1395+
An object of this type is returned by the IMAP4.idle() method.
1396+
It sends the IDLE command when activated by the 'with' statement, produces
1397+
IMAP untagged responses via the iterator protocol, and sends DONE upon
1398+
context exit.
1399+
1400+
Iteration produces (type, datum) tuples. They slightly differ
1401+
from the tuples returned by IMAP4.response(): The second item in the
1402+
tuple is a single datum, rather than a list of them, because only one
1403+
untagged response is produced at a time.
1404+
1405+
Note: The name and structure of this class are internal interfaces,
1406+
subject to change. Calling code can rely on its context management,
1407+
iteration, and public method to remain stable, but should not
1408+
subclass, instantiate, or otherwise directly reference the class.
1409+
"""
13941410

13951411
def __init__(self, imap, dur=None):
13961412
if 'IDLE' not in imap.capabilities:

0 commit comments

Comments
 (0)