Skip to content

Commit

Permalink
Cache the result of loading pyproject.toml file
Browse files Browse the repository at this point in the history
This change adds the functools cache decorator to avoid repeated
calls to _get_package_config, which results in IO hits to read
a file.

Closes reflex-dev#3341

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
  • Loading branch information
ericwb committed May 19, 2024
1 parent 656914e commit dcd92fd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions reflex/custom_components/custom_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
from collections import namedtuple
from contextlib import contextmanager
from functools import lru_cache
from pathlib import Path
from typing import Optional, Tuple

Expand Down Expand Up @@ -70,6 +71,7 @@ def _create_package_config(module_name: str, package_name: str):
)


@lru_cache(maxsize=None)
def _get_package_config(exit_on_fail: bool = True) -> dict:
"""Get the package configuration from the pyproject.toml file.
Expand Down

0 comments on commit dcd92fd

Please sign in to comment.