Browse Source

Fix bug of not calling __del__ of Map and Batch

tags/v1.1.0
hesham 5 years ago
parent
commit
f45fa1672b
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      mindspore/dataset/engine/datasets.py

+ 3
- 1
mindspore/dataset/engine/datasets.py View File

@@ -124,7 +124,7 @@ class Dataset:


self.parent = [] self.parent = []
for child in self.children: for child in self.children:
child.parent.append(self)
child.parent.append(weakref.ref(self))
self.num_parallel_workers = num_parallel_workers self.num_parallel_workers = num_parallel_workers


# todo check the following: # todo check the following:
@@ -1945,6 +1945,7 @@ class BatchDataset(Dataset):


def __del__(self): def __del__(self):
if hasattr(self, 'process_pool') and self.process_pool is not None: if hasattr(self, 'process_pool') and self.process_pool is not None:
logger.info("Batch process pool is being terminated.")
self.process_pool.close() self.process_pool.close()




@@ -2376,6 +2377,7 @@ class MapDataset(Dataset):


def __del__(self): def __del__(self):
if hasattr(self, 'process_pool') and self.process_pool is not None: if hasattr(self, 'process_pool') and self.process_pool is not None:
logger.info("Map process pool is being terminated.")
self.process_pool.close() self.process_pool.close()






Loading…
Cancel
Save