panel
panel copied to clipboard
Make `--setup` work with `--num-procs`
Resolves #6891
Postpone the execution to the start the server.
It needs a bit more thought than what I have given it. This is mostly a POC right now.
# app.py
import panel as pn
pn.pane.Markdown("Hello World").servable()
# background_job.py
from datetime import datetime
import os
import panel as pn
current_time = datetime.now()
def task() -> None:
"""Refresh the data in the database."""
print(f"Ran task at {datetime.now()} (PID {os.getpid()})")
pn.state.schedule_task(name="load_data", callback=task, at=current_time, period="5s")
Command: panel serve app.py --setup background_job.py --num-procs 2
https://github.com/holoviz/panel/assets/19758978/035e6f2d-269d-49a2-a46a-38669f793a92