diff --git a/daemons/lvmdbusd/background.py b/daemons/lvmdbusd/background.py index fc92b0cde..f4cb5398b 100644 --- a/daemons/lvmdbusd/background.py +++ b/daemons/lvmdbusd/background.py @@ -7,7 +7,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import threading import subprocess from . import cfg from .cmdhandler import options_to_cli_args @@ -15,9 +14,6 @@ import dbus from .utils import pv_range_append, pv_dest_ranges, log_error, log_debug import os -_rlock = threading.RLock() -_thread_list = list() - def pv_move_lv_cmd(move_options, lv_full_name, pv_source, pv_source_range, pv_dest_range_list): @@ -130,17 +126,3 @@ def merge(interface_name, lv_uuid, lv_name, merge_options, job_state): raise dbus.exceptions.DBusException( interface_name, 'LV with uuid %s and name %s not present!' % (lv_uuid, lv_name)) - - -def background_reaper(): - with _rlock: - num_threads = len(_thread_list) - 1 - if num_threads >= 0: - for i in range(num_threads, -1, -1): - _thread_list[i].join(0) - if not _thread_list[i].is_alive(): - log_debug("Reaping thread: %s" % _thread_list[i].name) - _thread_list.pop(i) - return True - - diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py index 5fe1018ae..7d10bc3b2 100644 --- a/daemons/lvmdbusd/main.py +++ b/daemons/lvmdbusd/main.py @@ -22,7 +22,6 @@ from . import lvmdb from gi.repository import GLib from .fetch import load from .manager import Manager -from .background import background_reaper import traceback import queue from . import udevwatch @@ -64,6 +63,7 @@ def _discard_pending_refreshes(): def process_request(): while cfg.run.value != 0: + # noinspection PyBroadException try: req = cfg.worker_q.get(True, 5) @@ -156,10 +156,8 @@ def main(): cfg.db = lvmdb.DataStore(cfg.args.use_json) - # Periodically call function to reap threads that are created - GLib.timeout_add(5000, background_reaper) - - # Using a thread to process requests. + # Using a thread to process requests, we cannot hang the dbus library + # thread that is handling the dbus interface thread_list.append(threading.Thread(target=process_request)) cfg.load(refresh=False, emit_signal=False, need_main_thread=False)