Skip to content

Control flow

Use mo.stop to halt execution of a cell, and optionally output an object. This function is useful for validating user input.

marimo.stop

stop(
    predicate: bool, output: Optional[object] = None
) -> None

Stops execution of a cell when predicate is True

When predicate is True, this function raises a MarimoStopError. If uncaught, this exception stops execution of the current cell and makes output its output. Any descendants of this cell that were previously scheduled to run will not be run, and their defs will be removed from program memory.

Example:

mo.stop(form.value is None, mo.md("**Submit the form to continue.**"))

Raises:

When predicate is True, raises a MarimoStopError.

Use mo.ui.refresh to trigger other cells to run periodically, on a configurable interval (or on click).