Repository: pytorch
Issue: Useless Exception traces when DataSet timing out
Labels: module: bootcamp,module: dataloader,triaged

Steps to reproduce:
1) Install pytorch master
2) Install torchvision master
3) Install https://github.com/pytorch/examples
4) Modify torchvision to introduce random timeouts inside of ImageFolder class (and reinstall)
```
diff --git a/torchvision/datasets/folder.py b/torchvision/datasets/folder.py
index dffa0a9..bcc871b 100644
--- a/torchvision/datasets/folder.py
+++ b/torchvision/datasets/folder.py
@@ -153,6 +153,10 @@ IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tif
 def pil_loader(path):
     # open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
     with open(path, 'rb') as f:
+        import time
+        import random
+        if random.random() > 0.999:
+            time.sleep(10000)
         img = Image.open(f)
         return img.convert('RGB')
```
5) Run imagenet example from https://github.com/pytorch/examples
6) When training stuck try to Ctrl+C or Kill child process do get useless Exception traces

Interrupted with Ctrl+C

```
(p38) ➜  imagenet git:(master) ✗ python main.py -b 32 --gpu 1 --epochs 20 --workers 8 -a resnet50 data
List
__name__
Optional
'_SpecialForm' object has no attribute '__name__'
Set
__name__
main.py:97: UserWarning: You have chosen a specific GPU. This will completely disable data parallelism.
  warnings.warn('You have chosen a specific GPU. This will completely '
Use GPU: 1 for training
=> creating model 'resnet50'
Epoch: [0][  0/778]     Time  3.059 ( 3.059)    Data  0.476 ( 0.476)    Loss 7.8664e+00 (7.8664e+00)    Acc@1   0.00 (  0.00)   Acc@5   0.00 (  0.00)
Epoch: [0][ 10/778]     Time  0.639 ( 0.830)    Data  0.000 ( 0.043)    Loss 2.8784e+01 (2.5900e+01)    Acc@1  46.88 ( 46.88)   Acc@5 100.00 ( 90.91)
Epoch: [0][ 20/778]     Time  0.641 ( 0.739)    Data  0.000 ( 0.038)    Loss 3.3539e+00 (1.4972e+01)    Acc@1  34.38 ( 47.17)   Acc@5 100.00 ( 95.24)
Epoch: [0][ 30/778]     Time  0.637 ( 0.707)    Data  0.000 ( 0.037)    Loss 3.6132e+00 (1.2208e+01)    Acc@1  59.38 ( 47.98)   Acc@5 100.00 ( 96.77)
Epoch: [0][ 40/778]     Time  0.639 ( 0.690)    Data  0.000 ( 0.036)    Loss 1.6624e+01 (1.1439e+01)    Acc@1  37.50 ( 47.94)   Acc@5 100.00 ( 97.56)
Epoch: [0][ 50/778]     Time  0.637 ( 0.680)    Data  0.000 ( 0.035)    Loss 2.2245e+01 (1.0695e+01)    Acc@1  65.62 ( 48.65)   Acc@5 100.00 ( 98.04)
^CTraceback (most recent call last):
  File "main.py", line 420, in <module>
    main()
  File "main.py", line 115, in main
    main_worker(args.gpu, ngpus_per_node, args)
  File "main.py", line 241, in main_worker
    train(train_loader, model, criterion, optimizer, epoch, args)
  File "main.py", line 275, in train
    for i, (input, target) in enumerate(train_loader):
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 424, in __next__
    data = self._next_data()
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 1058, in _next_data
    idx, data = self._get_data()
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 1014, in _get_data
    success, data = self._try_get_data()
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 862, in _try_get_data
    data = self._data_queue.get(timeout=timeout)
  File "/private/home/vitalyf/anaconda3/envs/p38/lib/python3.8/queue.py", line 179, in get
    self.not_empty.wait(remaining)
  File "/private/home/vitalyf/anaconda3/envs/p38/lib/python3.8/threading.py", line 306, in wait
    gotit = waiter.acquire(True, timeout)
KeyboardInterrupt
```

Interrupted with kill

```
(p38) ➜  imagenet git:(master) ✗ python main.py -b 32 --gpu 1 --epochs 20 --workers 8 -a resnet50 data
List
__name__
Optional
'_SpecialForm' object has no attribute '__name__'
Set
__name__
main.py:97: UserWarning: You have chosen a specific GPU. This will completely disable data parallelism.
  warnings.warn('You have chosen a specific GPU. This will completely '
Use GPU: 1 for training
=> creating model 'resnet50'
Epoch: [0][  0/778]     Time  3.022 ( 3.022)    Data  0.479 ( 0.479)    Loss 7.1807e+00 (7.1807e+00)    Acc@1   0.00 (  0.00)   Acc@5   0.00 (  0.00)
Traceback (most recent call last):
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 862, in _try_get_data
    data = self._data_queue.get(timeout=timeout)
  File "/private/home/vitalyf/anaconda3/envs/p38/lib/python3.8/queue.py", line 179, in get
    self.not_empty.wait(remaining)
  File "/private/home/vitalyf/anaconda3/envs/p38/lib/python3.8/threading.py", line 306, in wait
    gotit = waiter.acquire(True, timeout)
  File "/home/vitalyf/pytorch/torch/utils/data/_utils/signal_handling.py", line 66, in handler
    _error_if_any_worker_fails()
RuntimeError: DataLoader worker (pid 30019) is killed by signal: Terminated. 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 420, in <module>
    main()
  File "main.py", line 115, in main
    main_worker(args.gpu, ngpus_per_node, args)
  File "main.py", line 241, in main_worker
    train(train_loader, model, criterion, optimizer, epoch, args)
  File "main.py", line 275, in train
    for i, (input, target) in enumerate(train_loader):
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 424, in __next__
    data = self._next_data()
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 1058, in _next_data
    idx, data = self._get_data()
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 1014, in _get_data
    success, data = self._try_get_data()
  File "/home/vitalyf/pytorch/torch/utils/data/dataloader.py", line 875, in _try_get_data
    raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str))
RuntimeError: DataLoader worker (pid(s) 30019) exited unexpectedly
```

None of this traces identify `time.sleep(10000)` as 'stuck' instruction.

cc @SsnL @VitalyFedyunin