1
votes

I have a continuously running python process that creates temporary files that I don't know how to read. I've tried using open with 'rb' and np.fromfile with float and int but the results don't make sense. I am honestly not sure when Python decides to make a temporary file, but regardless, since I can't interpret the data, can I prevent creation of the files in the first place? They fill up the hard drive and then crash the process.

**Edit:**The timing is such that I think a temp file is created every time I download a file from the internet with urllib.request. video, _http = urllib.request.urlretrieve(video_path)

Historical: I think python is creating the temporary files because I ran this utility (fnotifystat) that tells me when a file is touched in my /tmp/ directory.

Total   Open  Close   Read  Write   PID  Process         Pathname
152.0    2.0    1.0    6.0  143.0  18978 python          /tmp/tmpqsj_h99n
  4.0    1.0    1.0    0.0    2.0  18978 python          /tmp/x13i7gh5

Total   Open  Close   Read  Write   PID  Process         Pathname
 32.0    0.0    0.0   32.0    0.0  18978 python          /tmp/tmpqsj_h99n
1
Is it your python program? Python doesn't create temporary files unless the code tells it to - user1558604
Interesting. There is no tempfile import anywhere in my code. I'll update my question with the evidence I have python is creating the files. - DanGoodrick
What is the extension of the tempfile and where is it going? - user1558604
no extension and to the /tmp/ folder - DanGoodrick
are you using any packages which might be making the temp files? - user1558604

1 Answers

1
votes

urllib.request.urlretrieve does indeed create temporary files. urllib.request.urlcleanup() removes them.