Skip to content

Commit

Permalink
check func_hash is defined before clearing (#5981)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored and philippjfr committed Dec 12, 2023
1 parent f88d3f7 commit 5395e31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions panel/io/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ def wrapped_func(*args, **kwargs):

def clear(session_context=None):
global func_hash
# clear called before anything is cached.
if 'func_hash' not in globals():
return
if func_hash is None:
return
if to_disk:
Expand Down
7 changes: 7 additions & 0 deletions panel/tests/io/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ def test_cache_clear():
fn.clear()
assert fn(0, 0) == 1

def test_cache_clear_before_cached():
# https://github.com/holoviz/panel/issues/5968
global OFFSET
OFFSET.clear()
fn = cache(function_with_args)
fn.clear()

def test_per_session_cache(document):
global OFFSET
OFFSET.clear()
Expand Down

0 comments on commit 5395e31

Please sign in to comment.