Refs #30323 -- Prevented crash of autoreloader when get_resolver().urlconf_module raising an exception.

This commit is contained in:
Tom Forbes 2019-04-29 10:22:43 +02:00 committed by Mariusz Felisiak
parent b5259ab780
commit 0636d4d2aa
2 changed files with 9 additions and 1 deletions

View File

@ -272,7 +272,12 @@ class BaseReloader:
from django.urls import get_resolver from django.urls import get_resolver
# Prevent a race condition where URL modules aren't loaded when the # Prevent a race condition where URL modules aren't loaded when the
# reloader starts by accessing the urlconf_module property. # reloader starts by accessing the urlconf_module property.
get_resolver().urlconf_module try:
get_resolver().urlconf_module
except Exception:
# Loading the urlconf can result in errors during development.
# If this occurs then swallow the error and continue.
pass
logger.debug('Apps ready_event triggered. Sending autoreload_started signal.') logger.debug('Apps ready_event triggered. Sending autoreload_started signal.')
autoreload_started.send(sender=self) autoreload_started.send(sender=self)
self.run_loop() self.run_loop()

View File

@ -64,3 +64,6 @@ Bugfixes
permissions for proxy models if the target permissions already existed. For permissions for proxy models if the target permissions already existed. For
example, when a permission had been created manually or a model had been example, when a permission had been created manually or a model had been
migrated from concrete to proxy (:ticket:`30351`). migrated from concrete to proxy (:ticket:`30351`).
* Fixed a regression in Django 2.2 that caused a crash of :djadmin:`runserver`
when URLConf modules raised exceptions (:ticket:`30323`).