diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2019-04-12 06:15:18 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-06-20 12:29:43 +0200 |
| commit | a415ce70bef6d91036b00dd2c8544aed7aeeaaed (patch) | |
| tree | 3583cef22e9b56d2ed52456ab586d9c47620bc51 /django/urls | |
| parent | cce47ff65a4dd3786c049ec14ee889e128ca7de9 (diff) | |
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.
Diffstat (limited to 'django/urls')
| -rw-r--r-- | django/urls/base.py | 7 | ||||
| -rw-r--r-- | django/urls/resolvers.py | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/django/urls/base.py b/django/urls/base.py index 1200d9a25b..0e1c3d909c 100644 --- a/django/urls/base.py +++ b/django/urls/base.py @@ -1,6 +1,7 @@ -from threading import local from urllib.parse import urlsplit, urlunsplit +from asgiref.local import Local + from django.utils.encoding import iri_to_uri from django.utils.functional import lazy from django.utils.translation import override @@ -12,10 +13,10 @@ from .utils import get_callable # SCRIPT_NAME prefixes for each thread are stored here. If there's no entry for # the current thread (which is the only one we ever access), it is assumed to # be empty. -_prefixes = local() +_prefixes = Local() # Overridden URLconfs for each thread are stored here. -_urlconfs = local() +_urlconfs = Local() def resolve(path, urlconf=None): diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py index 9d3379a821..af0508f94e 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -8,10 +8,11 @@ attributes of the resolved URL match. import functools import inspect import re -import threading from importlib import import_module from urllib.parse import quote +from asgiref.local import Local + from django.conf import settings from django.core.checks import Error, Warning from django.core.checks.urls import check_resolver @@ -380,7 +381,7 @@ class URLResolver: # urlpatterns self._callback_strs = set() self._populated = False - self._local = threading.local() + self._local = Local() def __repr__(self): if isinstance(self.urlconf_name, list) and self.urlconf_name: |
