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,6 +49,7 @@ class InfiniteDataLoader(dataloader.DataLoader):
|
|||
|
||||
def __del__(self):
|
||||
"""Ensure that workers are terminated."""
|
||||
if hasattr(self.iterator, "_workers"):
|
||||
for w in self.iterator._workers: # force terminate
|
||||
if w.is_alive():
|
||||
w.terminate()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue