From cf97bbe2996d1f413876c10cc9f3ca9a552aa37a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 25 Apr 2017 15:26:56 -0400 Subject: [PATCH] Rework ipmi worker management Provide a more concrete measurement of children, rather than relying upon a sentinel value on the queue. It seems that even using 'finally' didn't assure that we always get that sentinel value before a worker dies. Sentinel value still used to avoid a long wait in the usual case. --- .../plugins/hardwaremanagement/ipmi.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index ce92b869..ff8adbb2 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -273,17 +273,23 @@ def perform_requests(operator, nodes, element, cfg, inputdata): configdata = cfg.get_node_attributes(nodes, _configattributes) cfg.decrypt = cryptit resultdata = queue.LightQueue() - pendingnum = len(nodes) + livingthreads = set([]) for node in nodes: - _ipmiworkers.spawn_n( + livingthreads.add(_ipmiworkers.spawn( perform_request, operator, node, element, configdata, inputdata, - cfg, resultdata) - while pendingnum: - datum = resultdata.get() - if datum == 'Done': - pendingnum -= 1 - else: - yield datum + cfg, resultdata)) + while livingthreads: + try: + datum = resultdata.get(timeout=10) + while datum: + if datum != 'Done': + yield datum + datum = resultdata.get_nowait() + except queue.Empty: + pass + for t in list(livingthreads): + if t.dead: + livingthreads.discard(t) def perform_request(operator, node, element,