From e5d612529a1e9e2e12d0c5a322821e7dbb175be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 26 Aug 2015 16:00:09 +0200 Subject: Fix multithreading --- scripts/loop.py | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/scripts/loop.py b/scripts/loop.py index d464e30..ad87f18 100755 --- a/scripts/loop.py +++ b/scripts/loop.py @@ -48,19 +48,7 @@ def measure(kernelimg, con): boot.boot(con) print("Configuration '" + con.hash + "' measured.") -# Threads # -__terminate__ = False -class mainThread(Thread): - def run(self): - if conf.single_loop: - img, config = prepare() - measure(img, config) - else: - while not __terminate__: - img, config = prepare() - measure(img, config) - -# Multithread section # +# Multithread # __conflist__ = set() __listlock__ = Lock() @@ -102,19 +90,25 @@ __measurethread__ = measureThread() def sigterm_handler(_signo, _stack_frame): __terminate__ = True +# Main loop and single thread # def loop(): utils.dirtycheck() initialize.all() - global thr - thr = mainThread() - thr.start() - try: - thr.join() - except KeyboardInterrupt: - __terminate__ = True + if conf.multithread: + __preparethread__.start() + __measurethread__.start() + else: + if conf.single_loop: + img, config = prepare() + measure(img, config) + else: + while not __terminate__: + img, config = prepare() + measure(img, config) ################################################################################# if __name__ == '__main__': signal.signal(signal.SIGTERM, sigterm_handler) + signal.signal(signal.SIGINT, sigterm_handler) loop() -- cgit v1.2.3