From a415ce70bef6d91036b00dd2c8544aed7aeeaaed Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 12 Apr 2019 06:15:18 -0700 Subject: Fixed #30451 -- Added ASGI handler and coroutine-safety. This adds an ASGI handler, asgi.py file for the default project layout, a few async utilities and adds async-safety to many parts of Django. --- django/test/signals.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'django/test') diff --git a/django/test/signals.py b/django/test/signals.py index a623e756ce..31a5017602 100644 --- a/django/test/signals.py +++ b/django/test/signals.py @@ -1,8 +1,9 @@ import os -import threading import time import warnings +from asgiref.local import Local + from django.apps import apps from django.core.exceptions import ImproperlyConfigured from django.core.signals import setting_changed @@ -26,7 +27,7 @@ COMPLEX_OVERRIDE_SETTINGS = {'DATABASES'} def clear_cache_handlers(**kwargs): if kwargs['setting'] == 'CACHES': from django.core.cache import caches - caches._caches = threading.local() + caches._caches = Local() @receiver(setting_changed) @@ -113,7 +114,7 @@ def language_changed(**kwargs): if kwargs['setting'] in {'LANGUAGES', 'LANGUAGE_CODE', 'LOCALE_PATHS'}: from django.utils.translation import trans_real trans_real._default = None - trans_real._active = threading.local() + trans_real._active = Local() if kwargs['setting'] in {'LANGUAGES', 'LOCALE_PATHS'}: from django.utils.translation import trans_real trans_real._translations = {} -- cgit v1.3