Loading django/core/apps/cache.py +2 −6 Original line number Diff line number Diff line "Utilities for loading models and the modules that contain them." from collections import OrderedDict import imp from importlib import import_module import os import sys Loading @@ -9,7 +8,7 @@ import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils.module_loading import module_has_submodule from django.utils.module_loading import import_lock, module_has_submodule from django.utils._os import upath from django.utils import six Loading Loading @@ -74,8 +73,7 @@ class AppCache(object): # without holding the importer lock and another thread then tries to # import something which also launches the app loading. For details of # this situation see #18251. imp.acquire_lock() try: with import_lock(): if self.loaded: return for app_name in settings.INSTALLED_APPS: Loading @@ -86,8 +84,6 @@ class AppCache(object): for app_name in self.postponed: self.load_app(app_name) self.loaded = True finally: imp.release_lock() def load_app(self, app_name, can_postpone=False): """ Loading django/utils/module_loading.py +13 −0 Original line number Diff line number Diff line from __future__ import absolute_import # Avoid importing `importlib` from this package. from contextlib import contextmanager import copy import imp from importlib import import_module Loading Loading @@ -35,6 +36,18 @@ def import_by_path(dotted_path, error_prefix=''): return attr @contextmanager def import_lock(): """ Context manager that aquires the import lock. """ imp.acquire_lock() try: yield finally: imp.release_lock() def autodiscover_modules(*args, **kwargs): """ Auto-discover INSTALLED_APPS modules and fail silently when Loading Loading
django/core/apps/cache.py +2 −6 Original line number Diff line number Diff line "Utilities for loading models and the modules that contain them." from collections import OrderedDict import imp from importlib import import_module import os import sys Loading @@ -9,7 +8,7 @@ import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils.module_loading import module_has_submodule from django.utils.module_loading import import_lock, module_has_submodule from django.utils._os import upath from django.utils import six Loading Loading @@ -74,8 +73,7 @@ class AppCache(object): # without holding the importer lock and another thread then tries to # import something which also launches the app loading. For details of # this situation see #18251. imp.acquire_lock() try: with import_lock(): if self.loaded: return for app_name in settings.INSTALLED_APPS: Loading @@ -86,8 +84,6 @@ class AppCache(object): for app_name in self.postponed: self.load_app(app_name) self.loaded = True finally: imp.release_lock() def load_app(self, app_name, can_postpone=False): """ Loading
django/utils/module_loading.py +13 −0 Original line number Diff line number Diff line from __future__ import absolute_import # Avoid importing `importlib` from this package. from contextlib import contextmanager import copy import imp from importlib import import_module Loading Loading @@ -35,6 +36,18 @@ def import_by_path(dotted_path, error_prefix=''): return attr @contextmanager def import_lock(): """ Context manager that aquires the import lock. """ imp.acquire_lock() try: yield finally: imp.release_lock() def autodiscover_modules(*args, **kwargs): """ Auto-discover INSTALLED_APPS modules and fail silently when Loading