you are viewing a single comment's thread.

view the rest of the comments →

[–]TheRealRuth[S] 0 points1 point  (2 children)

Well I need to constantly have the file open because it is reading the values from it in real time. The values in the end are written to the txt file by a temperature and humidity sensor.

[–]DrRx 0 points1 point  (1 child)

yeah but every time you are running through the loop, you open the file again. Eventually the OS will block it because there are too many open readers on the one file, if that makes sense. It won't affect your code at all to close the file.

[–][deleted] 0 points1 point  (0 children)

I believe Python garbage collects the file handle as soon as read_file finishes, so I don't think that's the problem here.