diff options
| author | pgjones <philip.graham.jones@googlemail.com> | 2020-01-19 17:34:12 +0000 |
|---|---|---|
| committer | pgjones <philip.graham.jones@googlemail.com> | 2020-01-19 17:53:22 +0000 |
| commit | 3f9bcb5125a2e4067a2dff08f32c8e11b12f24aa (patch) | |
| tree | fb5a896cee4695869f599e2c66a0d66f64ca6fb8 | |
| parent | 889bf9233b37c9f861c858862f7f0f97eb81b225 (diff) | |
| download | werkzeug-lock.tar.gz | |
Allow the lock type to be customised in the routinglock
This will allow a subclass to specify a different type of lock,
specifically an asyncio or trio lock in order for the routing to be
used with these event loops. Note that gevent/eventlet monkey patch
Lock so nothing has been or is required for their usage.
| -rw-r--r-- | CHANGES.rst | 2 | ||||
| -rw-r--r-- | src/werkzeug/routing.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 22baeae0..229abd30 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -92,6 +92,8 @@ Unreleased properties to the ``Request`` and ``Response`` wrappers. :pr:`1699` - ``Accept`` values are no longer ordered alphabetically for equal quality tags. Instead the initial order is preserved. :issue:`1686` +- Added Map.lock_class attribute for alternative + implementations. :pr:`1702` Version 0.16.1 diff --git a/src/werkzeug/routing.py b/src/werkzeug/routing.py index aa07892c..fa71e698 100644 --- a/src/werkzeug/routing.py +++ b/src/werkzeug/routing.py @@ -1372,6 +1372,10 @@ class Map(object): #: A dict of default converters to be used. default_converters = ImmutableDict(DEFAULT_CONVERTERS) + #: The type of lock to use when updating. + #: .. versionadded:: 1.0 + lock_class = Lock + def __init__( self, rules=None, @@ -1389,7 +1393,7 @@ class Map(object): self._rules = [] self._rules_by_endpoint = {} self._remap = True - self._remap_lock = Lock() + self._remap_lock = self.lock_class() self.default_subdomain = default_subdomain self.charset = charset |
