Skip to content

Commit

Permalink
feat(layout): add kwargs to AbstractLayout.start()
Browse files Browse the repository at this point in the history
These kwargs get forwarded to `App.run_server()`. An example of `exec_mode` is provided in the
documentation.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
  • Loading branch information
psavery committed Apr 1, 2022
1 parent 0659fa8 commit 8b539a8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions trame/layouts/core.py
Expand Up @@ -99,7 +99,7 @@ def _init_app(self, _app):
if isinstance(template, AbstractElement):
route["component"]["template"] = template.html

def start(self, port=None, debug=None):
def start(self, port=None, debug=None, **kwargs):
"""
Start the application server.
Expand All @@ -108,6 +108,13 @@ def start(self, port=None, debug=None):
None, in which case it is set to True if the --dev
flag was passed as a command line argument.
:type debug: bool or None
:param kwargs: arguments to forward to run_server()
Some of the kwargs that may be forwarded to run_server() include:
* exec_mode (str): "main" (default) or "task" for running in an
environment that already has an event loop,
such as a Jupyter notebook.
"""
_app = tri.get_app_instance()

Expand All @@ -128,7 +135,7 @@ def start(self, port=None, debug=None):
# Dev validation
tri.validate_key_names()

_app.run_server(port=port)
_app.run_server(port=port, **kwargs)

def start_thread(
self, port=None, print_server_info=False, on_server_listening=None, **kwargs
Expand Down

0 comments on commit 8b539a8

Please sign in to comment.