#9589 closed Bug (fixed)
development server stops on SyntaxError or other Exceptions
Reported by: | eibaan | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It's a bit annoying that you have to manually restart the development server if you have a
SyntaxError
, ImportError
or NameError
in a file because changes to that file are not detected.
This is caused - I think - by the fact that the autoreloader only watches files of successfully loaded modules.
I created a patch that catches those errors and adds fake modules to the system so that the autoreloader also checks for changes in those files. It's kind of hackish but it causes the reload after fixing the problems as wished for.
Attachments (3)
Change History (19)
by , 16 years ago
Attachment: | autoreload-r9410.patch added |
---|
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 16 years ago
I'd rather see it stay how it is now, though error messages should make it clear that any "no reverse exception" errors might be caused by errors while importing views.
comment:3 by , 16 years ago
mtredinnick, please notice that after an exception, no code is (or should) actually running anymore. The system stopps responding and only the background thread looking for file changes is still active. This is how the system behaves for all other exceptions already. I just added support for SyntaxError
and ImportError
. Fixing those problems in files is not detected by the background thread right now. I tried to add them. Faking modules seemed to be the easiest way to do so. Because I do not use "real" module names, there shouldn't be any strange side effects.
anonymous, this hasn't to do with "no reverse exception". My patch fixes the problem that after you made a syntax error in some file, the development server breaks down and has to be restarted manually.
comment:4 by , 16 years ago
This problem is pretty annoying, but I think this fix is a bit too much of a hack. I don't think it'll actually cause problems, but the attached patch should be a bit cleaner. It needs testing with jython_reloader.
by , 16 years ago
Attachment: | autoreload.diff added |
---|
fixed 'exceptions.TypeError' object has no attribute 'filename'
comment:5 by , 15 years ago
#11957 reported problems in this area with errors in admin.py files specifically. Not sure whether that is covered by the change proposed here.
comment:6 by , 15 years ago
I've created a patch that uses a decorator to solve this problem. When main() is called to start the reloader, the function passed in is wrapped in a decorator that currently catches IndentationError, NameError, SyntaxError, or TypeError. When one these exceptions is found, the file that caused the error is added to a list of watched files. This list is checked for modifications in addition to the files found in sys.modules.
by , 15 years ago
Attachment: | autoreload-error_decorator-r11628.patch added |
---|
Added decorator that checks for file errors and adds them to watch list.
comment:7 by , 15 years ago
I have updated patch autoreload-error_decorator-r11628.patch, which now handles ImportError as well.
comment:8 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I agree with Malcolm, so I'm marking this wontfix.
comment:9 by , 15 years ago
With who? This is very obviously a bug, and an annoying one. It makes no sense to wontfix this.
comment:10 by , 15 years ago
To respond more usefully (and less out of simple bewilderment), and assuming that "mtredinnick" is Malcolm (it would be helpful to not use names that make other people do research to follow a ticket; use the names being used in the tracker):
He responded to the initial patch, which had the bizarre behavior of modifying the global modules table (which should almost always be treated as read-only), and which nobody else liked either. That's why there are rewritten patches which eliminate that problem. I'm confused because you closed the bug agreeing that the first patch wasn't acceptable, despite the clean patches offered later by myself and berto.
comment:11 by , 15 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
Version: | 1.0 → 1.1 |
No response in over a month, and my inquiry on django-dev was ignored, so I'm reopening this. The reason for closing it made no sense. If you reclose it, please do those of us who have spent time fixing this the courtesy of giving a meaningful explanation, and not just pointing to a reason that's six months irrelevant which multiple other people have long since corrected.
comment:12 by , 14 years ago
Component: | django-admin.py runserver → Core (Management commands) |
---|
comment:13 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:14 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → duplicate |
Status: | reopened → closed |
UI/UX: | unset |
This problem was first reported in #8413. That ticket has a patch with a different technique.
comment:15 by , 12 years ago
Resolution: | duplicate → fixed |
---|
This looks like a cure that's worse than the disease. After installing this fake module, you're now no longer running the correct code, so all sorts of unexpected things could happen, which will be quite misleading.
Given that the current error handling, although possibly a little annoying from time to time, is very explicit and doesn't result in incorrect behaviour, I prefer the current stuff. -1 from me on this patch.