From 0636d4d2aa6e4469198fdf662225ad862e60c5e3 Mon Sep 17 00:00:00 2001 From: Tom Forbes Date: Mon, 29 Apr 2019 10:22:43 +0200 Subject: [PATCH] Refs #30323 -- Prevented crash of autoreloader when get_resolver().urlconf_module raising an exception. --- django/utils/autoreload.py | 7 ++++++- docs/releases/2.2.1.txt | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index 17631e15ef..dc7c9b2cea 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -272,7 +272,12 @@ class BaseReloader: from django.urls import get_resolver # Prevent a race condition where URL modules aren't loaded when the # 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.') autoreload_started.send(sender=self) self.run_loop() diff --git a/docs/releases/2.2.1.txt b/docs/releases/2.2.1.txt index 9696488e14..4a2d77aaf3 100644 --- a/docs/releases/2.2.1.txt +++ b/docs/releases/2.2.1.txt @@ -64,3 +64,6 @@ Bugfixes permissions for proxy models if the target permissions already existed. For example, when a permission had been created manually or a model had been 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`).