When I'm using vim to edit files in a django application that is running in developer mode I sometimes encounter this crash coming from the auto-reload utility:

File "/home/zefciu/.virtualenvs/15five/lib/python3.6/site-packages/django/utils/autoreload.py", line 207, in code_changed
    stat = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory:

What I understand is, that django is trying to check for a file that due to the way vim handles saving doesn't exist in that moment. This causes django to crash instead of reloading the application as it is meant to.

I would like to provide a patch for this crash, so in this situation, django would wait and retry the operation. I have no idea, however, what should be a sensible timeout for this? How long should I wait for the file to appear again?

  • 2
    Are the files read-only (but with write permissions on the directory)? In that case, Vim actually deletes and recreates the file, but otherwise it just writes to the file and the file doesn't go missing. Also, which OS, filesystem, etc.? – muru Jul 26 '18 at 1:18
  • It's likely related to 'backupcopy'. – jamessan Jul 29 '18 at 14:19
  • @muru the files are not read-only. I am using Linux with ext4 filesystem @jamessan I don't have backupcopy explicitly set up. How to check which of the strategies is my vim actually using? – zefciu Aug 9 '18 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.