#23083 closed Bug (fixed)
dev server autoreload: OSError: [Errno 2] No such file or directory
Reported by: | Collin Anderson | Owned by: | Tim Graham |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.7-rc-1 |
Severity: | Release blocker | Keywords: | |
Cc: | cmawebsite@…, hirokiky@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
on django 1.7, sometimes, when I'm saving a file, I'll get this error:
File "/home/collin/saintmarys/django/core/management/base.py", line 363, in run_from_argv self.execute(*args, **cmd_options) File "/home/collin/saintmarys/django/core/management/base.py", line 412, in execute output = self.handle(*args, **options) File "/home/collin/saintmarys/django/core/management/commands/runserver.py", line 80, in handle self.run(**options) File "/home/collin/saintmarys/django/core/management/commands/runserver.py", line 89, in run autoreload.main(self.inner_run, None, options) File "/home/collin/saintmarys/django/utils/autoreload.py", line 324, in main reloader(wrapped_main_func, args, kwargs) File "/home/collin/saintmarys/django/utils/autoreload.py", line 290, in python_reloader reloader_thread() File "/home/collin/saintmarys/django/utils/autoreload.py", line 266, in reloader_thread change = fn() File "/home/collin/saintmarys/django/utils/autoreload.py", line 204, in code_changed stat = os.stat(filename) OSError: [Errno 2] No such file or directory: '/home/collin/saintmarys/main/views.py'
This never happened to me when editing python files on django 1.6. Would it make sense to catch this error and reload when this happens?
Attachments (2)
Change History (17)
comment:1 by , 10 years ago
Component: | Uncategorized → Core (Management commands) |
---|---|
Severity: | Normal → Release blocker |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
Yup, that works for me. I guess it's actually pretty easy to reproduce: simply delete the file.
I assume it's another regression from _cached_filenames
.
comment:3 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 10 years ago
Has patch: | set |
---|
Here is an actual patch. I used the tutorial and make a request to /polls/, then deleted polls/views.py, but the server didn't reload nor was there an error, so I'm not sure about testing it. I guess writing a test probably isn't feasible but let me know if you have an idea for that.
by , 10 years ago
Attachment: | 23083.diff added |
---|
comment:5 by , 10 years ago
I just tried the tutorial also. If I install inotify, things work fine, but when inotify is not installed, I get this issue when deleting polls/views.py.
comment:6 by , 10 years ago
Actually, I have a feeling this code might not work correctly in the .mo case, but I don't use .mo files.
comment:7 by , 10 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
Maybe Claude can look at the issue as he's worked on this code more than I.
comment:8 by , 10 years ago
Cc: | added |
---|
It's regression caused by this ticket https://code.djangoproject.com/ticket/9722
and not so difficult (Of cause, I don't blame anybody).
And the reason is that the _cached_filenames
stores file names even if some files are deleted:
- Lack of codes to clean up deleted files from _cached_filenames
- the sys.modules provides modules which is already deleted. so it's difficult to notice the deletion by '_cached_modules == set(sys.modules.values()).
By Timo's patch, os.stat causes OSError every time and the error will be globed.
(I'm not sure about OSErrors provided by os.stat, but it's not good to glob errors blindly)
comment:11 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thanks for caring for this issue, I was a bit short of time.
comment:12 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Seems reasonable. I guess we'd just make this modification?