# Dataset: Loading from the same file with more than a single thread

**URL:** <https://discuss.pytorch.org/t/dataset-loading-from-the-same-file-with-more-than-a-single-thread/73323>\
**Category:** Uncategorized\
**Created:** [March 15, 2020, 11:15pm UTC](https://discuss.pytorch.org/t/dataset-loading-from-the-same-file-with-more-than-a-single-thread/73323 "2020-03-15T23:15:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Frank-Jing](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/frank-jing/32/43546_2.png) [@Frank-Jing](https://discuss.pytorch.org/u/Frank-Jing)\
**Post date:** [November 2, 2021, 8:42am UTC](https://discuss.pytorch.org/t/dataset-loading-from-the-same-file-with-more-than-a-single-thread/73323/2 "2021-11-02T08:42:15Z")

</div>

When using multi workers to load data, you’d better to reserve file-descriptor in workers(i.e in **getitem** () method), not in main process(i.e. in **init** () method).  
You can refer this post(and it’s reply): [DataLoader, when num\_worker \>0, there is bug - #14 by piojanu](https://discuss.pytorch.org/t/dataloader-when-num-worker-0-there-is-bug/25643/14)

---

_[View the full topic](https://discuss.pytorch.org/t/dataset-loading-from-the-same-file-with-more-than-a-single-thread/73323)._
