Fix dataloader cleanup error with no workers (#18732)
Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
This commit is contained in:
parent
b1042c4da8
commit
309f5cafc1
1 changed files with 5 additions and 4 deletions
|
|
@ -49,10 +49,11 @@ class InfiniteDataLoader(dataloader.DataLoader):
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
"""Ensure that workers are terminated."""
|
"""Ensure that workers are terminated."""
|
||||||
for w in self.iterator._workers: # force terminate
|
if hasattr(self.iterator, "_workers"):
|
||||||
if w.is_alive():
|
for w in self.iterator._workers: # force terminate
|
||||||
w.terminate()
|
if w.is_alive():
|
||||||
self.iterator._shutdown_workers() # cleanup
|
w.terminate()
|
||||||
|
self.iterator._shutdown_workers() # cleanup
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue