3 ms·
I'm lost between the no-true-scotsmen and strawmen the post tries to construct. The advice about closing the descriptors is for practical reasons. There's no n
by viraptor 6y ago
I'm lost between the no-true-scotsmen and strawmen the post tries to construct.
The advice about closing the descriptors is for practical reasons. There's no need for "true believers" taking that advice to extreme. Just like clearing the dict if you're dropping the reference anyway is useless.
If you can consume the file immediately, you can close it. If you're doing lazy iteration you have to keep it open, and I don't understand why that's an issue.
- Someone 6y ago“If you're doing lazy iteration you have to keep it open, and I don't understand why that's an issue.” It isn’t an issue if you process a few files that way (unless you’re running your system very close to the limit), but it is an issue if you have a long running process that lazily iterates over files often. Examples are iterating over a file system (say a kind of grep) or a web server where an often called entry point does this.
- viraptor 6y agoSure. But I was getting at something different. You can choose your open files limit on one side and the approach (lazy or not) on the other. If you choose lazy there's no way around having to leave the file open.