Running Python on a Raspberry Pi, I found that my /tmp folder was becoming full over time. On investigation, I found that it was becoming full of files of the form /tmp/python.cache_root/<1>/<2>/, where <1> and <2> are oct digits. These files were created when I ran a scheduled (self-written) Python script.
Googling "Python Caching" and related terms only turned up results from frameworks or products like Maya or Django, which were no good to me. Apologies if I've missed an obvious result!
Is this a sign of sloppy coding (e.g. unclosed resources), or simply something that Python does as a by-product of running scripts? Is there an accepted way to deal with this? Running rm -rf /tmp/* "solves" the problem, as does rebooting the Pi, but obviously these aren't desirable solutions.
EDIT: It's been suggested that the python-twitter library might be to blame, as per this bug
You are probably using the python-twitter project; it creates a temporary directory with the name python.cache_<username>, with that exact structure (based on a md5 hash).
On Raspberry you are running your code as root usually, so that fits.
Another python library that uses the exact same structure is python-lastfm; the code was obviously copied between projects. Both projects have sprouted a few forks, so the method may be more widespread still.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With