Skip to content

Commit

Permalink
Improve Skip handling
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 4, 2024
1 parent d8df0d8 commit 1c0fdd4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
try:
from param import Skip
except Exception:
class Skip(RuntimeError):
class Skip(Exception):
"""
Exception that allows skipping an update for function-level updates.
"""
from param.parameterized import (
classlist, discard_events, eval_function_with_deps, get_method_owner,
iscoroutinefunction, resolve_ref, resolve_value,
Undefined, classlist, discard_events, eval_function_with_deps,
get_method_owner, iscoroutinefunction, resolve_ref, resolve_value,
)
from param.reactive import rx

Expand Down Expand Up @@ -842,9 +842,14 @@ async def _eval_async(self, awaitable):
pass
else:
try:
self._update_inner(await awaitable)
new = await awaitable
if new is Skip or new is Undefined:
raise Skip
self._update_inner(new)
except Skip:
pass
self.param.log(
param.DEBUG, 'Skip event was raised, skipping update.'
)
except Exception as e:
if not curdoc or (has_context and curdoc.session_context):
raise e
Expand All @@ -865,7 +870,12 @@ def _replace_pane(self, *args, force=False):
else:
try:
new_object = self.eval(self.object)
if new_object is Skip and new_object is Undefined:
raise Skip
except Skip:
self.param.log(
param.DEBUG, 'Skip event was raised, skipping update.'
)
return
if inspect.isawaitable(new_object) or isinstance(new_object, types.AsyncGeneratorType):
param.parameterized.async_executor(partial(self._eval_async, new_object))
Expand Down

0 comments on commit 1c0fdd4

Please sign in to comment.