Skip to content

Commit

Permalink
Do not piggyback on Tornado event loop for periodic callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 7, 2025
1 parent fda7cfd commit 32ba68e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions panel/io/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,16 @@ def start(self):
finally:
self._updating = False
self._start_time = time.time()
if state._is_pyodide:
self._cb = asyncio.create_task(
self._async_repeat(self._periodic_callback)
)
elif state.curdoc and state.curdoc.session_context:
if state.curdoc and state.curdoc.session_context and not state._is_pyodide:
self._doc = state.curdoc
if state._unblocked(state.curdoc):
self._cb = self._doc.add_periodic_callback(self._periodic_callback, self.period)
else:
self._doc.add_next_tick_callback(self.start)
else:
from tornado.ioloop import PeriodicCallback
self._cb = PeriodicCallback(lambda: asyncio.create_task(self._periodic_callback()), self.period)
self._cb.start()
self._cb = asyncio.create_task(
self._async_repeat(self._periodic_callback)
)

def stop(self):
"""
Expand Down

0 comments on commit 32ba68e

Please sign in to comment.