Skip to content
Myr

deprecate locked_cached_property

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent c690f52 · Browse files · 4 files+22 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+22 added−6 removed

  • other:+22 added−6 removed

4 files+22 added−6 removed

modified:src/flask/app.py+4 added-4 removed
24 unmodified lines
25from werkzeug.routing import RoutingException26from werkzeug.routing import Rule27from werkzeug.serving import is_running_from_reloader28from werkzeug.urls import url_quote29from werkzeug.utils import cached_property30from werkzeug.utils import redirect as _wz_redirect31from werkzeug.wrappers import Response as BaseResponse3233from . import cli
12 unmodified lines
46from .helpers import _split_blueprint_path47from .helpers import get_debug_flag48from .helpers import get_flashed_messages49from .helpers import get_load_dotenv49from .helpers import locked_cached_property50from .json.provider import DefaultJSONProvider51from .json.provider import JSONProvider52from .logging import create_logger53from .scaffold import _endpoint_from_view_func
476 unmodified lines
530 " needed to set up the application are done before"531 " running it."532 )533534 @locked_cached_property534 @cached_property535 def name(self) -> str: # type: ignore536 """The name of the application. This is usually the import name537 with the difference that it's guessed from the run file if the538 import name is main. This name is used as a display name when
8 unmodified lines
547 return "__main__"548 return os.path.splitext(os.path.basename(fn))[0]549 return self.import_name550551 @locked_cached_property551 @cached_property552 def logger(self) -> logging.Logger:553 """A standard Python :class:`~logging.Logger` for the app, with554 the same name as :attr:`name`.555
18 unmodified lines
574 .. versionadded:: 0.3575 """576 return create_logger(self)577578 @locked_cached_property578 @cached_property579 def jinja_env(self) -> Environment:580 """The Jinja environment used to load templates.581582 The environment is created the first time this property is
1645 unmodified lines
modified:src/flask/helpers.py+12 added
611 unmodified lines
612 """A :func:`property` that is only evaluated once. Like613 :class:`werkzeug.utils.cached_property` except access uses a lock614 for thread safety.615616 .. deprecated:: 2.3617 Will be removed in Flask 2.4. Use a lock inside the decorated function if618 locking is needed.619620 .. versionchanged:: 2.0621 Inherits from Werkzeug's ``cached_property`` (and ``property``).622 """623
2 unmodified lines
626 fget: t.Callable[[t.Any], t.Any],627 name: t.Optional[str] = None,628 doc: t.Optional[str] = None,629 ) -> None:630 import warnings631632 warnings.warn(633 "'locked_cached_property' is deprecated and will be removed in Flask 2.4."634 " Use a lock inside the decorated function if locking is needed.",635 DeprecationWarning,636 stacklevel=2,637 )638 super().__init__(fget, name=name, doc=doc)639 self.lock = RLock()640641 def __get__(self, obj: object, type: type = None) -> t.Any: # type: ignore
43 unmodified lines
modified:src/flask/scaffold.py+2 added-2 removed
9 unmodified lines
1011from jinja2 import FileSystemLoader12from werkzeug.exceptions import default_exceptions13from werkzeug.exceptions import HTTPException14from werkzeug.utils import cached_property1516from . import typing as ft17from .cli import AppGroup18from .globals import current_app19from .helpers import get_root_path19from .helpers import locked_cached_property20from .helpers import send_from_directory21from .templating import _default_template_ctx_processor2223if t.TYPE_CHECKING: # pragma: no cover
292 unmodified lines
316 return send_from_directory(317 t.cast(str, self.static_folder), filename, max_age=max_age318 )319320 @locked_cached_property320 @cached_property321 def jinja_loader(self) -> t.Optional[FileSystemLoader]:322 """The Jinja loader for this object's templates. By default this323 is a class :class:`jinja2.loaders.FileSystemLoader` to324 :attr:`template_folder` if it is set.
597 unmodified lines
modified:CHANGES.rst+4 added
24 unmodified lines
2526- Importing ``escape`` and ``Markup`` from ``flask`` is deprecated. Import them27 directly from ``markupsafe`` instead. :pr:`4996`28- The ``app.got_first_request`` property is deprecated. :pr:`4997`29- The ``locked_cached_property`` decorator is deprecated. Use a lock inside the30 decorated function if locking is needed. :issue:`4993`31- Remove uses of locks that could cause requests to block each other very briefly.32 :issue:`4993`33- Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.34 :pr:`4947`35- Ensure subdomains are applied with nested blueprints. :issue:`4834`36
1418 unmodified lines