fix: tummy stuck when calculating log size
Timmy can get stuck on proc.join() if queue has not been collected and the queue does not fit into the system pipe buffer. This fix adds a loop in which we try to get data from the queue and then join the process but with a 1 second timeout, so we don't block forever. Closes-Bug: https://github.com/adobdin/timmy/issues/66 Change-Id: I0d96a7c8aa6823bc5c22c4b6b74e4897d52d4332
This commit is contained in:
parent
851e279185
commit
de323f534b
@ -16,7 +16,7 @@
|
||||
# under the License.
|
||||
|
||||
project_name = 'timmy'
|
||||
version = '1.23.1'
|
||||
version = '1.23.2'
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
@ -163,17 +163,24 @@ def run_batch(item_list, maxthreads, dict_result=False):
|
||||
proc.terminate()
|
||||
proc.join()
|
||||
|
||||
def get_result(proc, key, results):
|
||||
try:
|
||||
results[key] = proc.queue.get(block=False)
|
||||
except Queue.Empty:
|
||||
if not proc.is_alive():
|
||||
logger.warning(emp_msg % proc.pid)
|
||||
|
||||
def collect_results(l, join=False):
|
||||
results = {}
|
||||
remove_procs = []
|
||||
for key, proc in l.items():
|
||||
if not proc.is_alive() or join:
|
||||
logger.debug('joining subprocess, pid: %s' % proc.pid)
|
||||
proc.join()
|
||||
try:
|
||||
results[key] = proc.queue.get(block=False)
|
||||
except Queue.Empty:
|
||||
logger.warning(emp_msg % proc.pid)
|
||||
while proc.is_alive():
|
||||
get_result(proc, key, results)
|
||||
proc.join(timeout=1)
|
||||
if key not in results:
|
||||
get_result(proc, key, results)
|
||||
if key in results and isinstance(results[key], Exception):
|
||||
exc_text = proc.queue.get()
|
||||
logger.critical(exc_msg % proc.pid)
|
||||
|
Loading…
x
Reference in New Issue
Block a user