diff options
author | Patrick Bellasi <patrick.bellasi@arm.com> | 2017-10-12 14:51:19 +0100 |
---|---|---|
committer | Patrick Bellasi <patrick.bellasi@arm.com> | 2017-10-12 15:01:28 +0100 |
commit | 4a6aacef992e1d5b78f9d80004936fb540740bf5 (patch) | |
tree | 001ae8836cf72f0b0d5a3799cba3947b5a31754e | |
parent | 9837b4012bcf94d1fe97361e4fe0d50229428ea3 (diff) | |
download | devlib-4a6aacef992e1d5b78f9d80004936fb540740bf5.tar.gz |
Instrument/Acmecape: ensure iio-capture termination
Once an ACME cape instrument is released, if the stop() method has not
been called by the client code, let's ensure to release the channels by
killing the corresponding iio-caputure process.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
-rw-r--r-- | devlib/instrument/acmecape.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/devlib/instrument/acmecape.py b/devlib/instrument/acmecape.py index 818094f..5c10598 100644 --- a/devlib/instrument/acmecape.py +++ b/devlib/instrument/acmecape.py @@ -58,6 +58,12 @@ class AcmeCapeInstrument(Instrument): self.add_channel('device', 'current') self.add_channel('timestamp', 'time_ms') + def __del__(self): + if self.process and self.process.pid: + self.logger.warning('killing iio-capture process [%d]...', + self.process.pid) + self.process.kill() + def reset(self, sites=None, kinds=None, channels=None): super(AcmeCapeInstrument, self).reset(sites, kinds, channels) self.raw_data_file = tempfile.mkstemp('.csv')[1] @@ -98,6 +104,7 @@ class AcmeCapeInstrument(Instrument): .format(self.process.returncode, output)) if not os.path.isfile(self.raw_data_file): raise HostError('Output CSV not generated.') + self.process = None def get_data(self, outfile): if os.stat(self.raw_data_file).st_size == 0: |