From aeb27d70ecd4e2728337cca66d39f93a48e6ca20 Mon Sep 17 00:00:00 2001 From: Ingo Meyer Date: Tue, 1 Mar 2022 13:32:43 +0100 Subject: Fix blocked idler on calling the `stop` method Calling the idler `stop` method sends a signal to the internally used thread to finish its work. However, this thread is already blocked by the IMAP IDLE mode and only released after reaching the IDLE timeout. Thus, this commit sends another IMAP command (a simple NOOP) to abort the IDLE mode so the thread can be released without any delay. This commit fixes GitHub issue #26. --- ayatanawebmail/idler.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ayatanawebmail') diff --git a/ayatanawebmail/idler.py b/ayatanawebmail/idler.py index 8f956ea..3e852a1 100755 --- a/ayatanawebmail/idler.py +++ b/ayatanawebmail/idler.py @@ -22,6 +22,9 @@ class Idler(object): def stop(self): + if self.oConnection.oImap is not None: + # Send a NOOP command to interrupt the IDLE mode and free the blocked thread + self.oConnection.oImap.noop() self.oEvent.set() def join(self): -- cgit v1.2.3