Skip to content
Snippets Groups Projects
Commit 0fc439ee authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Print profile output if we were called with --profile and we were killed via TERM.

parent d77ff3a3
No related branches found
No related tags found
No related merge requests found
Pipeline #386913 passed
......@@ -728,6 +728,7 @@ def run_diffoscope(parsed_args):
def sigterm_handler(signo, stack_frame):
logger.warning("Received TERM signal; cleaning up temp files...")
clean_all_temp_files()
ProfileManager().finish()
logger.warning("Exiting...")
os._exit(2)
......
......@@ -60,9 +60,17 @@ class ProfileManager:
self.data[namespace][key]["time"] += time.time() - start
self.data[namespace][key]["count"] += 1
def finish(self, parsed_args):
def finish(self, parsed_args=None):
from .presenters.utils import make_printer
# We are being called in the TERM handler so we don't have access to
# parsed_args. Print the profiling output to stderr if we have been
# collecting it.
if parsed_args is None:
if _ENABLED:
self.output(lambda x: print(x, file=sys.stderr))
return
# Include profiling in --debug output if --profile is not set.
if parsed_args.profile_output is None:
with setup_logging(parsed_args.debug, None) as logger:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment