Reputation: 3208
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
Upvotes: 1
Views: 1087
Reputation: 3208
urllib.request.urlretrieve
does indeed create temporary files.
urllib.request.urlcleanup()
removes them.
Upvotes: 2