def _wait_finish(self): print("Wait for workers to die: {}".format(self._input_source_name)) for w in self._workers: if w != threading.current_thread(): w.join(5.0) # don't wait forever, thread may be blocked in i/o success = True for w in self._workers: if w.isAlive(): print("Worker {} failed to close while waiting".format(w)) success = False # Release memory for the scratch blobs if success: utils.ResetBlobs(self._scratch_blob.values()) utils.ResetBlobs(self._scratch_status.values()) print("All workers terminated: {}".format(success)) return success
def _stop(self, reason=None): try: self._active = False if reason is not None: log.error( "Data input failed due to an error: {}".format(reason)) for q in self._queues: workspace.RunOperatorOnce( core.CreateOperator("CloseBlobsQueue", [q], [])) # Release memory for the scratch blobs utils.ResetBlobs(self._scratch_blobs) self._started = False finally: self._log_inputs_per_interval(0, force=True)
def cleanup(self): utils.ResetBlobs(self._scratch_blob.values()) utils.ResetBlobs(self._scratch_status.values())