I/O error on Google Colab in streaming mode
Opened by jotterbach (closed)

## Describe the bug
When trying to load a streaming dataset in Google Colab the loading fails with an I/O error

## Steps to reproduce the bug
```python
import datasets
from datasets import load_dataset
hf_ds = load_dataset(path='wmt19', name='cs-en', streaming=True, split=datasets.Split.VALIDATION)
list(hf_ds.take(5))
```

## Expected results
It should load five data points

## Actual results
```
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-13-7b5b8b1e7e58>](https://localhost:8080/#) in <module>
      2 from datasets import load_dataset
      3 hf_ds = load_dataset(path='wmt19', name='cs-en', streaming=True, split=datasets.Split.VALIDATION)
----> 4 list(hf_ds.take(5))

6 frames
[/usr/local/lib/python3.7/dist-packages/datasets/iterable_dataset.py](https://localhost:8080/#) in __iter__(self)
    716 
    717     def __iter__(self):
--> 718         for key, example in self._iter():
    719             if self.features:
    720                 # `IterableDataset` automatically fills missing columns with None.

[/usr/local/lib/python3.7/dist-packages/datasets/iterable_dataset.py](https://localhost:8080/#) in _iter(self)
    706         else:
    707             ex_iterable = self._ex_iterable
--> 708         yield from ex_iterable
    709 
    710     def _iter_shard(self, shard_idx: int):

[/usr/local/lib/python3.7/dist-packages/datasets/iterable_dataset.py](https://localhost:8080/#) in __iter__(self)
    582 
    583     def __iter__(self):
--> 584         yield from islice(self.ex_iterable, self.n)
    585 
    586     def shuffle_data_sources(self, generator: np.random.Generator) -> "TakeExamplesIterable":

[/usr/local/lib/python3.7/dist-packages/datasets/iterable_dataset.py](https://localhost:8080/#) in __iter__(self)
    110 
    111     def __iter__(self):
--> 112         yield from self.generate_examples_fn(**self.kwargs)
    113 
    114     def shuffle_data_sources(self, generator: np.random.Generator) -> "ExamplesIterable":

[~/.cache/huggingface/modules/datasets_modules/datasets/wmt19/aeadcbe9f1cbf9969e603239d33d3e43670cf250c1158edf74f5f6e74d4f21d0/wmt_utils.py](https://localhost:8080/#) in _generate_examples(self, split_subsets, extraction_map, with_translation)
    845                 raise ValueError("Invalid number of files: %d" % len(files))
    846 
--> 847             for sub_key, ex in sub_generator(*sub_generator_args):
    848                 if not all(ex.values()):
    849                     continue

[~/.cache/huggingface/modules/datasets_modules/datasets/wmt19/aeadcbe9f1cbf9969e603239d33d3e43670cf250c1158edf74f5f6e74d4f21d0/wmt_utils.py](https://localhost:8080/#) in _parse_parallel_sentences(f1, f2, filename1, filename2)
    923         l2_sentences, l2 = parse_file(f2_i, filename2)
    924 
--> 925         for line_id, (s1, s2) in enumerate(zip(l1_sentences, l2_sentences)):
    926             key = f"{f_id}/{line_id}"
    927             yield key, {l1: s1, l2: s2}

[~/.cache/huggingface/modules/datasets_modules/datasets/wmt19/aeadcbe9f1cbf9969e603239d33d3e43670cf250c1158edf74f5f6e74d4f21d0/wmt_utils.py](https://localhost:8080/#) in gen()
    895 
    896         def gen():
--> 897             with open(path, encoding="utf-8") as f:
    898                 for line in f:
    899                     seg_match = re.match(seg_re, line)

ValueError: I/O operation on closed file.
```

## Environment info
Copy-and-paste the text below in your GitHub issue.

- `datasets` version: 2.4.0
- Platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.13
- PyArrow version: 9.0.0. (the same error happened with PyArrow version 6.0.0)
- Pandas version: 1.3.5




Comments: