diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 79ac7fb5c..355056390 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -341,8 +341,9 @@ class Account(object): def shutdown(self, wait=True): """ stop threads and close and remove underlying dc_context and callbacks. """ if hasattr(self, "_dc_context"): + self.stop_threads(wait=False) # to interrupt idle and tell python threads to stop lib.dc_close(self._dc_context) - self.stop_threads(wait=wait) + self.stop_threads(wait=wait) # to wait for threads deltachat.clear_context_callback(self._dc_context) del self._dc_context @@ -392,12 +393,18 @@ class IOThreads: def imap_thread_run(self): while not self._thread_quitflag: lib.dc_perform_imap_jobs(self._dc_context) + if self._thread_quitflag: + break lib.dc_perform_imap_fetch(self._dc_context) + if self._thread_quitflag: + break lib.dc_perform_imap_idle(self._dc_context) def smtp_thread_run(self): while not self._thread_quitflag: lib.dc_perform_smtp_jobs(self._dc_context) + if self._thread_quitflag: + break lib.dc_perform_smtp_idle(self._dc_context) diff --git a/src/imap.rs b/src/imap.rs index 702a67c49..4ad6a9d35 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -468,7 +468,7 @@ impl Imap { fn unsetup_handle(&self, context: &Context) { info!(context, 0, "IMAP unsetup_handle starts"); - self.interrupt_idle(); + // self.interrupt_idle(); let session = self.session.lock().unwrap().0.take(); if session.is_some() { match session.unwrap().close() {