forked from mindspore-Ecosystem/mindspore
Fix bug of not calling __del__ of Map and Batch
This commit is contained in:
parent
d0e7ae66a4
commit
f45fa1672b
|
@ -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…
Reference in New Issue