Temp files in Python.

Recently, I hit a nasty bug while working with temp files in Python.

The issue was manifesting itself in Windows.  Interestingly I wasnt hitting it on Linux.

  • As it so turns out I would have eventually hit it on Linux too.


The issue was because of a leaked file descriptor.  The following link explains the issue

du command (Linux)


  • To find whats contributing to the disk usage on a specific filesystem (/dev/sda2)
    • This can be tricky because there would be other filesystems mounted underneath /
    • I have found the package ‘xdiskusage‘ very useful for this.
    • This problem is discussed here


  • If i need to look up directory sizes  only till 1 layer, then the following command is useful:
    • the ‘-s’ flag is useful to summarize the contents on directory


$ du -csh *
52K Desktop
4.0K Documents
0 media
4.0K Music
353M notebooks
4.0K Pictures
4.0K Public
4.0K Templates
947M transferLearning
4.0K Videos
1.3G total




C# OutOfProcess Python