Skip to content

Commit

Permalink
Add --warm option to panel serve (#1971)
Browse files Browse the repository at this point in the history
* Add --warm-cache option to panel serve

* Rename --warm-cache to --warm
  • Loading branch information
philippjfr committed Feb 12, 2021
1 parent 2cb9d02 commit 8e49e6b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions panel/command/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from urllib.parse import urljoin

from bokeh.command.subcommands.serve import Serve as _BkServe
from bokeh.command.util import build_single_handler_applications

from ..auth import OAuthProvider
from ..config import config
Expand Down Expand Up @@ -111,6 +112,10 @@ class Serve(_BkServe):
type = int,
help = "The length of the session history to record.",
default = 0
)),
('--warm', dict(
action = 'store_true',
help = "Whether to execute scripts on startup to warm up the server."
))
)

Expand Down Expand Up @@ -143,6 +148,12 @@ def customize_kwargs(self, args, server_kwargs):
with edit_readonly(state):
state.base_url = urljoin('/', prefix)

if args.warm:
argvs = {f: args.args for f in files}
applications = build_single_handler_applications(files, argvs)
for app in applications.values():
app.create_document()

# Handle tranquilized functions in the supplied functions
if args.rest_provider in REST_PROVIDERS:
pattern = REST_PROVIDERS[args.rest_provider](files, args.rest_endpoint)
Expand Down

0 comments on commit 8e49e6b

Please sign in to comment.