From 79fd585145adeb18d4a9afb764a991595de8560b Mon Sep 17 00:00:00 2001 From: "N. Sanchirico" Date: Fri, 28 Jul 2023 13:27:52 -0400 Subject: [PATCH] increment periodic callback counter before executing callback; update logic to signal a stop --- panel/io/callbacks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/panel/io/callbacks.py b/panel/io/callbacks.py index 21d3dcfbb3..e762b1e517 100644 --- a/panel/io/callbacks.py +++ b/panel/io/callbacks.py @@ -82,7 +82,11 @@ def _exec_callback(self, post=False): from .state import set_curdoc try: with set_curdoc(self._doc): - cb = self.callback() + if self.running: + self.counter += 1 + if self.counter > self.count: + self.stop() + cb = self.callback() if self.running else None except Exception: cb = None if post: @@ -98,7 +102,6 @@ def _post_callback(self): if not self._background: with edit_readonly(state): state._busy_counter -= 1 - self.counter += 1 if self.timeout is not None: dt = (time.time() - self._start_time) * 1000 if dt > self.timeout: