summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-07-17 20:55:11 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-07-26 10:36:11 -0700
commit4bd5878ce01d86f9635f3e736cea0022a6e26b46 (patch)
tree0012663e0ca877aa8b4729759e247e4cabe35030 /alot
parentb644b7142cb8f2277d7cf08135b9a9b636de1bf3 (diff)
db/manager: use threads instead of reactor.callInThread
This is the obvious thing to do, and it works, but it does introduce some latency into starting alot.
Diffstat (limited to 'alot')
-rw-r--r--alot/db/manager.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/alot/db/manager.py b/alot/db/manager.py
index 0ea9e7db..80af88bd 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -8,10 +8,10 @@ import multiprocessing
import os
import signal
import sys
+import threading
from notmuch import Database, NotmuchError, XapianError
import notmuch
-from twisted.internet import reactor
from . import DB_ENC
from .errors import DatabaseError
@@ -352,10 +352,14 @@ class DBManager(object):
logging.debug('Worker process %s %s', process.pid, msg)
self.processes.remove(process)
+ # XXX: it would be much nicer to run this as a coroutine than a thread,
+ # except that this code is executed before the eventloop is started.
+ #
# spawn a thread to collect the worker process once it dies
# preventing it from hanging around as zombie
- reactor.callInThread(threaded_wait)
+ threading.Thread(target=threaded_wait).start()
+ # TODO: avoid this if logging level > debug
def threaded_reader(prefix, fd):
with os.fdopen(fd) as handle:
for line in handle:
@@ -364,9 +368,11 @@ class DBManager(object):
# spawn two threads that read from the stdout and stderr pipes
# and write anything that appears there to the log
- reactor.callInThread(threaded_reader, 'stdout', stdout[0])
+ threading.Thread(target=threaded_reader,
+ args=('stdout', stdout[0])).start()
os.close(stdout[1])
- reactor.callInThread(threaded_reader, 'stderr', stderr[0])
+ threading.Thread(target=threaded_reader,
+ args=('stderr', stderr[0])).start()
os.close(stderr[1])
# closing the sending end in this (receiving) process guarantees