From fb3c8e339fb3896753f7130b8f8e34be8d89ae2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 13 Aug 2015 11:19:09 +0200 Subject: Fix thread cooperation in loop Measure function requires img and config as atributes. But only config was provided. --- scripts/loop.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/loop.py b/scripts/loop.py index aecda39..9cc8ddb 100755 --- a/scripts/loop.py +++ b/scripts/loop.py @@ -58,7 +58,7 @@ class mainThread(Thread): measure(img, config) # Multithread section # -__conflist__ = [] +__conflist__ = set() __listlock__ = Lock() class prepareThread(Thread): @@ -69,11 +69,11 @@ class prepareThread(Thread): while not __terminate__ and len(__conflist__) <= conf.multithread_buffer: __listlock__.release() try: - config = prepare() + img, config = prepare() except exceptions.NoApplicableConfiguration: return __listlock__.aquire() - __conflist__.append(config) + __conflist__.add((img, config)) if not __measurethread__.isActive(): __measurethread__.start() __listlock__.release() @@ -84,12 +84,11 @@ class measureThread(Thread): def run(self): __listlock__.aquire() while not __terminate__ and len(__conflist__) > 0: - config = __conflist__[0] - del __conflist__[0] + img, config = __conflist__.pop() __listlock__.release() if not __preparethread__.isActive(): __preparethread__.start() - measure(config) + measure(img, config) __listlock__.aquire() __listlock__.release() -- cgit v1.2.3