Commit 68077327 authored by Alexandre Boyer's avatar Alexandre Boyer
Browse files

fix monitor with subprocess: ffmpeg issue + enhance exception with stacktrace

parent 12800ffa
Pipeline #125085 passed with stage
in 34 seconds
......@@ -93,7 +93,7 @@ class ActevCommand():
logging.info("%s done" % self.command)
StatusFactory.generate_status(self, 'done', args.__dict__)
except:
logging.error("Issue during %s" % self.command)
logging.exception("Issue during %s" % self.command)
StatusFactory.generate_status(self, 'issue', args.__dict__)
sys.exit(1)
......@@ -25,5 +25,5 @@ def entry_point(file_index, activity_index, chunks, nb_videos_per_chunk,
"""
exec(file_index, activity_index, chunks, nb_videos_per_chunk,
video_location, system_cache_dir, output_file, chunks_result, config_file)
video_location, system_cache_dir, config_file, output_file, chunks_result)
......@@ -49,7 +49,7 @@ output, chunk_result):
reset_chunk(chunk_id, system_cache_dir)
continue
merge_chunks(output, chunks_result, system_cache_dir)
merge_chunks(system_cache_dir, output, chunk_result, None)
experiment_cleanup()
except:
......
......@@ -62,24 +62,17 @@ class Monitor():
def run_monitor(self):
"""Runs the monitoring process
The `main_function` in a process and the
`monitoring_process()` function in another.
The `main_function` is executed and the
`monitoring_process()` function is in a process.
"""
self.main_process = Process(target=self.main_function, kwargs=self.args.__dict__)
# Instruction to listen to the signals
signal.signal(signal.SIGINT, self.signal_int_handler)
self.main_process.start()
self.main_process_pid = os.getpid()
self.main_function(**self.args.__dict__)
self.monitor = Process(target=self.monitor_resources)
self.monitor.daemon=True
self.monitor.start()
while self.main_process.exitcode is None:
pass
if self.main_process.exitcode != 0:
raise Exception
def increment_log_file(self, log_dict):
......@@ -108,7 +101,7 @@ class Monitor():
# Try to retrieve the main_process
try:
process = psutil.Process(self.main_process.pid)
process = psutil.Process(self.main_process_pid)
# Load the NVIDIA handler
with NvmlHandler() as nvml_h:
......@@ -133,15 +126,5 @@ class Monitor():
except Exception as e:
logger.debug(e)
logger.debug('PID {} not available for monitoring'.format(self.main_process.pid))
logger.debug('PID {} not available for monitoring'.format(self.main_process_pid))
def signal_int_handler(self, signal, frame):
"""
This function is called when using Ctrl-C,
it will kill the main subprocess
Args:
signal (:obj:`signal`): The signal that triggered the execution of this function
frame (:obj:`frame`): Stack frame
"""
self.main_process.terminate()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment