id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 28500,"""EOFError: Ran out of input"" from Django file cache when file is empty",Justin Crown,caleb logan,"When using Django file cache, if a cache file ends up empty for some reason (yes, this actually happened in the wild), an `EOFError` is thrown. Steps to reproduce: Cache must be set to `django.core.cache.backends.filebased.FileBasedCache`. {{{ >>> from django.core.cache import cache >>> cache.set('testing' 'test') }}} In a shell {{{ > cache_dir/file_that_got_created.djcache }}} Back in the REPL {{{ >>> cache.get('testing') Traceback (most recent call last): File ""/usr/local/lib/python3.6/code.py"", line 91, in runcode exec(code, self.locals) File """", line 1, in File ""/usr/local/lib/python3.6/site-packages/django/core/cache/backends/filebased.py"", line 40, in get if not self._is_expired(f): File ""/usr/local/lib/python3.6/site-packages/django/core/cache/backends/filebased.py"", line 137, in _is_expired exp = pickle.load(f) EOFError: Ran out of input }}} As to how these files would end up empty to begin with, I would hazard to guess that it is caused by a rare race condition in the file moving process: https://github.com/django/django/blob/master/django/core/files/move.py#L59 Whereby if this process is interrupted by a system shutdown, the file is created in the appropriate location but is empty. Desired behavior would be that in this situation, an exception would not be thrown. Rather, `None` (or default) would be returned. I am planning on working on a patch towards this, but wanted to log the ticket first.",Bug,closed,Core (Cache system),1.11,Normal,fixed,,,Accepted,0,0,0,0,0,0