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.
|
# under the License.
|
||||||
|
|
||||||
project_name = 'timmy'
|
project_name = 'timmy'
|
||||||
version = '1.23.1'
|
version = '1.23.2'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
@ -163,17 +163,24 @@ def run_batch(item_list, maxthreads, dict_result=False):
|
|||||||
proc.terminate()
|
proc.terminate()
|
||||||
proc.join()
|
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):
|
def collect_results(l, join=False):
|
||||||
results = {}
|
results = {}
|
||||||
remove_procs = []
|
remove_procs = []
|
||||||
for key, proc in l.items():
|
for key, proc in l.items():
|
||||||
if not proc.is_alive() or join:
|
if not proc.is_alive() or join:
|
||||||
logger.debug('joining subprocess, pid: %s' % proc.pid)
|
logger.debug('joining subprocess, pid: %s' % proc.pid)
|
||||||
proc.join()
|
while proc.is_alive():
|
||||||
try:
|
get_result(proc, key, results)
|
||||||
results[key] = proc.queue.get(block=False)
|
proc.join(timeout=1)
|
||||||
except Queue.Empty:
|
if key not in results:
|
||||||
logger.warning(emp_msg % proc.pid)
|
get_result(proc, key, results)
|
||||||
if key in results and isinstance(results[key], Exception):
|
if key in results and isinstance(results[key], Exception):
|
||||||
exc_text = proc.queue.get()
|
exc_text = proc.queue.get()
|
||||||
logger.critical(exc_msg % proc.pid)
|
logger.critical(exc_msg % proc.pid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user