[OE-core] [PATCH 1/2] oeqa/selftest/{context, case}: Add signal handlers SIG{INT, TERM}
Aníbal Limón
anibal.limon at linux.intel.com
Tue Jun 27 15:41:49 UTC 2017
On 06/27/2017 01:53 AM, Patrick Ohly wrote:
> On Mon, 2017-06-26 at 15:42 -0500, Aníbal Limón wrote:
>> def run(self, logger, args):
>> self._process_args(logger, args)
>> +
>> + signal.signal(signal.SIGTERM, self._signal_clean_handler)
>> + signal.signal(signal.SIGINT, self._signal_clean_handler)
>> +
>> rc = None
>>
>> if args.machine:
>> @@ -220,6 +264,8 @@ class
>> OESelftestTestContextExecutor(OETestContextExecutor):
>> os.remove(output_link)
>> os.symlink(args.output_log, output_link)
>>
>> + self._signal_clean_handler(None, None)
>> +
>
> Can't you achieve the same thing with less code by using a
> try:
> ... modify configuration ...
> ... run tests ...
> finally:
> ... clean up ...
> block in run()?
>
> Then you are also guaranteed to clean up if an unexpected exception
> triggers the aborting of run().
Yes but this will only work with SIGINT because it raises
KeyboardInterrupt exception but there is a need to set SIGTERM too.
Cheers,
Anibal
>
More information about the Openembedded-core
mailing list