#25634: runserver reloader masks exceptions
-------------------------------------+-------------------------------------
Reporter: wide-awake | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by unklphil):
This is a real problem, as it seems to label other exceptions as
`django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.`
I had a working Django 1.9rc2 application yesterday, but this morning when
I tried to run `runserver`, I got:
{{{
Traceback (most recent call last):
File "./manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/Users/phil/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 350, in
execute_from_command_line
utility.execute()
File "/Users/phil/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/phil/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 176, in fetch_command
commands = get_commands()
File "/Users/phil/env/lib/python2.7/site-
packages/django/utils/lru_cache.py", line 100, in wrapper
result = user_function(*args, **kwds)
File "/Users/phil/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 71, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/Users/phil/env/lib/python2.7/site-
packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/Users/phil/env/lib/python2.7/site-
packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
}}}
This was curious, as I hadn't changed any of the code or packages, so the
`AppRegistryNotReady` didn't make any sense.
After a lot of troubleshooting and googling, I found claudep's suggestion
of using `--noreload` to display the actual error and discovered that the
error had nothing to do with apps not being ready. The exception it was
masking was:
{{{
Traceback (most recent call last):
File "./manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/Users/phil/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 350, in
execute_from_command_line
utility.execute()
File "/Users/phil/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 324, in execute
django.setup()
File "/Users/phil/env/lib/python2.7/site-packages/django/__init__.py",
line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/phil/env/lib/python2.7/site-packages/django/utils/log.py",
line 71, in configure_logging
logging_config_func(logging_settings)
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py",
line 794, in dictConfig
dictConfigClass(config).configure()
File
"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py",
line 576, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler u'app_log_file': [Errno 2] No such
file or directory: u'/var/log/myapp/application.log'
}}}
Turns out an OS update removed my log directory, and it couldn't create
the logfiles on startup, but it took me about an hour of troubleshooting
to find this simple solution just because I was getting the wrong
exception the whole time.
IMO this is a major problem, because firstly, the `AppRegistryNotReady`
traceback is not helpful at all, because it doesn't tell you where the
problem is, and secondly, it's not even the correct exception.
Seeing as most Django developers use runserver to develop, I would even
consider labelling this as a release blocker.
--
Ticket URL: <https://code.djangoproject.com/ticket/25634#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.dafbbf94d4c2d22c0693582d27edd257%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.