diff --git a/pymosa/noise_occupancy_scan.py b/pymosa/noise_occupancy_scan.py index d76c815..780c399 100644 --- a/pymosa/noise_occupancy_scan.py +++ b/pymosa/noise_occupancy_scan.py @@ -85,7 +85,7 @@ def scan(self): for region in range(4): self.fake_hit_rate_meas[plane, region] = self.hit_occ_map[m26_regions[region][0]:m26_regions[region][1], :, plane].sum() / 576. / 288. / self.scan_timeout / 1e6 * 115.2 - self.hist_occ.stop.set() # stop analysis process + self.hist_occ.close() # stop analysis process # Log status (fake hit rate, noise occupoancy, threshold setting) self.print_log_status() diff --git a/pymosa/online.py b/pymosa/online.py index a312ffa..45671c9 100644 --- a/pymosa/online.py +++ b/pymosa/online.py @@ -330,11 +330,26 @@ def worker(self, raw_data_queue, shared_array_base, lock, stop): except queue.Empty: continue - def __del__(self): + def close(self): + ''' Close process and wait till done. Likely needed to give access to pytable file handle.''' + logger.info('Stopping process %d', self.p.pid) self._raw_data_queue.close() self._raw_data_queue.join_thread() # Needed otherwise IOError: [Errno 232] The pipe is being closed self.stop.set() self.p.join() + del self.p # explicit delete required to free memory + self.p = None + + def __del__(self): + if self.p and self.p.is_alive(): + logger.warning('Process still running. Was close() called?') + self.close() + + # def __del__(self): + # self._raw_data_queue.close() + # self._raw_data_queue.join_thread() # Needed otherwise IOError: [Errno 232] The pipe is being closed + # self.stop.set() + # self.p.join() if __name__ == "__main__":