diff --git a/bumblebee/modules/dnf.py b/bumblebee/modules/dnf.py index 0271665..bc40e94 100644 --- a/bumblebee/modules/dnf.py +++ b/bumblebee/modules/dnf.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import time import shlex import threading @@ -16,12 +18,26 @@ def description(): return "Checks DNF for updated packages and displays the number of /// pending updates." def get_dnf_info(obj): - while True: + + loops = 0 + + for thread in threading.enumerate(): + if thread.name == "MainThread": + main = thread + + while main.is_alive(): try: res = subprocess.check_output(shlex.split("dnf updateinfo")) except Exception as e: break + loops += 1 + time.sleep(1) + if loops < obj.interval(): + continue + + loops = 0 + security = 0 bugfixes = 0 enhancements = 0 @@ -47,13 +63,11 @@ def get_dnf_info(obj): obj.set("enhancements", enhancements) obj.set("other", other) - time.sleep(obj.interval()) - - class Module(bumblebee.module.Module): def __init__(self, output, args): super(Module, self).__init__(args) - self._interval = args[0] if args else 30*60 + + self._interval = int(args[0]) if args else 30*60 self._counter = {} self._thread = threading.Thread(target=get_dnf_info, args=(self,)) self._thread.start()