Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback on long callback function names if source cannot be found #3072

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dash/long_callback/managers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def get_updated_props(self, key):
raise NotImplementedError

def build_cache_key(self, fn, args, cache_args_to_ignore):
fn_source = inspect.getsource(fn)
try:
fn_source = inspect.getsource(fn)
fn_str = fn_source
except OSError: # pylint: disable=too-broad-exception
fn_str = getattr(fn, "__name__", "")

if not isinstance(cache_args_to_ignore, (list, tuple)):
cache_args_to_ignore = [cache_args_to_ignore]
Expand All @@ -68,7 +72,7 @@ def build_cache_key(self, fn, args, cache_args_to_ignore):
arg for i, arg in enumerate(args) if i not in cache_args_to_ignore
]

hash_dict = dict(args=args, fn_source=fn_source)
hash_dict = dict(args=args, fn_source=fn_str)

if self.cache_by is not None:
# Caching enabled
Expand Down