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

Fix race condition in periodic callback resulting in additional callback executions #5344

Merged
Merged
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
7 changes: 5 additions & 2 deletions panel/io/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down