From 0c7f65222c042cfe19727873e57f8ac7ac6af8d1 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Mon, 27 Jan 2020 23:30:47 +0300 Subject: [PATCH] fix(python): add workaround for interrupt_idle race condition --- python/src/deltachat/account.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 68b3d71b8..005ebfa59 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -578,6 +578,11 @@ class IOThreads: def stop(self, wait=False): self._thread_quitflag = True + + # Workaround for a race condition. Make sure that thread is + # not in between checking for quitflag and entering idle. + time.sleep(0.5) + lib.dc_interrupt_imap_idle(self._dc_context) lib.dc_interrupt_smtp_idle(self._dc_context) lib.dc_interrupt_mvbox_idle(self._dc_context)