summaryrefslogtreecommitdiff
path: root/alot/buffers
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-12-21 09:29:49 +0100
committerAnton Khirnov <anton@khirnov.net>2020-01-02 17:18:56 +0100
commit09d7db6dc591fbe44058b0e01acae331c52f0b28 (patch)
treec1ec33174778ae0e593453d510a030fe2b469f5d /alot/buffers
parentf1ceccaa58bb36cac73e6886a0b14230e5518fda (diff)
Revert "db/manager: Drop async method"
This reverts commit e7e0c52db9093a9ecd9dcaa0766e66515a546a75.
Diffstat (limited to 'alot/buffers')
-rw-r--r--alot/buffers/search.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/alot/buffers/search.py b/alot/buffers/search.py
index d64e857f..203ef483 100644
--- a/alot/buffers/search.py
+++ b/alot/buffers/search.py
@@ -6,7 +6,7 @@ from notmuch import NotmuchError
from .buffer import Buffer
from ..settings.const import settings
-from ..walker import IterableWalker
+from ..walker import PipeWalker
from ..widgets.search import ThreadlineWidget
@@ -26,6 +26,7 @@ class SearchBuffer(Buffer):
self.sort_order = sort_order or default_order
self.result_count = 0
self.isinitialized = False
+ self.proc = None # process that fills our pipe
self.rebuild()
Buffer.__init__(self, ui, self.body)
@@ -41,9 +42,22 @@ class SearchBuffer(Buffer):
info['result_count_positive'] = 's' if self.result_count > 1 else ''
return info
+ def cleanup(self):
+ self.kill_filler_process()
+
+ def kill_filler_process(self):
+ """
+ terminates the process that fills this buffers
+ :class:`~alot.walker.PipeWalker`.
+ """
+ if self.proc:
+ if self.proc.is_alive():
+ self.proc.terminate()
+
def rebuild(self, reverse=False):
self.isinitialized = True
self.reversed = reverse
+ self.kill_filler_process()
if reverse:
order = self._REVERSE[self.sort_order]
@@ -56,8 +70,9 @@ class SearchBuffer(Buffer):
try:
self.result_count = self.dbman.count_messages(self.querystring)
- threads = self.dbman.get_threads(
- self.querystring, order, exclude_tags)
+ self.pipe, self.proc = self.dbman.get_threads(self.querystring,
+ order,
+ exclude_tags)
except NotmuchError:
self.ui.notify('malformed query string: %s' % self.querystring,
'error')
@@ -65,9 +80,9 @@ class SearchBuffer(Buffer):
self.body = self.listbox
return
- self.threadlist = IterableWalker(threads, ThreadlineWidget,
- dbman=self.dbman,
- reverse=reverse)
+ self.threadlist = PipeWalker(self.pipe, ThreadlineWidget,
+ dbman=self.dbman,
+ reverse=reverse)
self.listbox = urwid.ListBox(self.threadlist)
self.body = self.listbox