Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Maarten Breddels <[email protected]>
  • Loading branch information
iisakkirotko and maartenbreddels committed Feb 8, 2024
1 parent 31eef74 commit e26db2f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions solara/website/pages/api/on_kernel_start.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e26db2f

Please sign in to comment.