7
My first Python script crashed because I forgot to close a file
I was working on a simple program yesterday to organize some text files. It ran fine for a few minutes, then just stopped with a weird error about too many open files. I spent an hour checking my logic before a friend asked if I was using 'with open'. I wasn't. I had opened each file but never closed them, so after about 500 files, the system gave up. I fixed it by adding a single 'with' statement. Has anyone else run into a simple mistake that caused a big headache like that?
2 comments
Log in to join the discussion
Log In2 Comments
hugo69924d ago
Oh man, that's the worst kind of bug. It's like leaving every faucet in your house on a tiny drip. You don't notice until the basement floods. I see it everywhere now, like not logging out of apps on shared devices or leaving a browser with a hundred tabs open. Small leaks that eventually just break the whole system. Makes you wonder what else we're all leaving open without realizing.
2
rileyh1024d ago
Disagree, hugo699, sometimes those small leaks are what keep the whole system running without us having to think about it.
3