Catch and ignore exception in dataloader cleanup (#18772)
Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
This commit is contained in:
parent
673b43ce17
commit
a2430d0478
1 changed files with 5 additions and 1 deletions
|
|
@ -49,11 +49,15 @@ class InfiniteDataLoader(dataloader.DataLoader):
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
"""Ensure that workers are terminated."""
|
"""Ensure that workers are terminated."""
|
||||||
if hasattr(self.iterator, "_workers"):
|
try:
|
||||||
|
if not hasattr(self.iterator, "_workers"):
|
||||||
|
return
|
||||||
for w in self.iterator._workers: # force terminate
|
for w in self.iterator._workers: # force terminate
|
||||||
if w.is_alive():
|
if w.is_alive():
|
||||||
w.terminate()
|
w.terminate()
|
||||||
self.iterator._shutdown_workers() # cleanup
|
self.iterator._shutdown_workers() # cleanup
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue