From e26db2f0739cb3ac212d6f0c1a5aedc2b17da148 Mon Sep 17 00:00:00 2001 From: Iisakki Rotko Date: Thu, 8 Feb 2024 15:38:36 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Maarten Breddels --- solara/website/pages/api/on_kernel_start.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/solara/website/pages/api/on_kernel_start.py b/solara/website/pages/api/on_kernel_start.py index e9cccf881..e3347337d 100644 --- a/solara/website/pages/api/on_kernel_start.py +++ b/solara/website/pages/api/on_kernel_start.py @@ -1,16 +1,18 @@ """ -# on_kernel_start API +# on_kernel_start -Solara provides a way to run code when the virtual python kernel (re)starts. +Run a function when a virtual kernel (re)starts and optionally run a cleanup function on shutdown. ```python def on_kernel_start(f: Callable[[], Optional[Callable[[], None]]]): ``` -`f` will be called on virtual kernel (re)start. This means that the callbacks are executed separately for all clients. -The (optional) function returned by `f` will be called on kernel close. +`f` will be called on each virtual kernel (re)start. This (usually) happens each time a browser tab connects to the server +[see solara server for more details](https://solara.dev/docs/understanding/solara-server). +The (optional) function returned by `f` will be called on kernel shutdown. -Note that the functions are called in inverse order with respect to the order they were registered in. +Note that the cleanup functions are called in reverse order with respect to the order in which they were registered +(e.g. the cleanup function of the last call to `on_kernel_start` will be called first on kernel shutdown) """ from . import NoPage