From 94ce286d1fd5ae92aabe98b3f6f27d5426c703c9 Mon Sep 17 00:00:00 2001 From: VG Date: Thu, 12 May 2016 17:37:54 +0200 Subject: Change time.time to time.monotonic This has less corner case and thus I could simplify function description by deleting the corner case note. --- climl/imap.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/climl/imap.py b/climl/imap.py index 30fa272..4616e01 100644 --- a/climl/imap.py +++ b/climl/imap.py @@ -90,19 +90,13 @@ def imap_waiter(connection): command and the begining of idle mode. If those events represent new mails, they will be checked at the idle timeout (it takes time to see them, but they are not lost). - - Note2: this function use time.time to check for timeout (in case the - server returns non-real-events like dovecot 2min keepalive messages), - this function can return (in case of system clock set) lower value - than a precendent call, but the only side effect will be a shorter - timeout which is not a deal breaker. ''' print('entering idle mode...') connection.idle() print('waiting for an event') try: - tenter = time.time() - while (time.time() - tenter) <= 24*60: + tenter = time.monotonic() + while (time.monotonic() - tenter) <= 24*60: events = connection.idle_check(timeout=24*60) if len(events) == 1 and \ str(bytes(events[0][0]), encoding='ascii') == 'OK': -- cgit v1.2.3