How to use _set_logfile_close_signal_handler method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...39 break40 timestamp += 141 logfile = gzip.GzipFile(logfile_name, 'w')42 return logfile43def _set_logfile_close_signal_handler(logfile):44 """Setup a signal handler to explicitly call logfile.close() and exit.45 Because we are writing a compressed file we need to make sure we properly46 close to flush our internal buffer on exit. sends us47 a SIGTERM and waits 5 seconds for before sending a SIGKILL so we have48 plenty of time to do this.49 :param logfile - An open file object to be closed on SIGTERM.50 """51 def _on_signal_close_logfile_before_exit(unused_signal_no, unused_frame):52 logfile.close()53 os.exit(1)54 signal.signal(signal.SIGTERM, _on_signal_close_logfile_before_exit)55def _unset_signal_handler():56 signal.signal(signal.SIGTERM, signal.SIG_DFL)57def main():58 (options, args) = parser.parse_args()59 if len(args) != 2:60 parser.print_help()61 sys.exit(1)62 logfile = _open_logfile(args[0])63 warnfile = os.fdopen(int(args[1]), 'w', 0)64 # For now we aggregate all the alert_hooks.65 alert_hooks = []66 for patterns_path in options.pattern_paths.split(','):67 alert_hooks.extend(monitors_util.build_alert_hooks_from_path(68 patterns_path, warnfile))69 _set_logfile_close_signal_handler(logfile)70 try:71 monitors_util.process_input(72 sys.stdin, logfile, options.log_timestamp_format, alert_hooks)73 finally:74 logfile.close()75 _unset_signal_handler()76if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?