bokeh.application.handlers.code_runner#
Provide a utility class CodeRunner
for use by handlers that execute
Python source code.
- class CodeRunner(source: str, path: PathLike, argv: list[str], package: ModuleType | None = None)[source]#
Compile and run Python source code.
Public Data Attributes:
Contents of docstring, if code contains one.
If code execution fails, may contain a related error message.
If code execution fails, may contain a traceback or other details.
True
if code execution failedThe path that new modules will be configured with.
The configured source code that will be executed when
run
is called.Public Methods:
__init__
(source, path, argv[, package])- param source:
A string containing Python source code to execute
Make a fresh module to run in.
Clears any transient error conditions from a previous run.
run
(module[, post_check])Execute the configured source code in a module and run any post checks.
- __init__(source: str, path: PathLike, argv: list[str], package: ModuleType | None = None) None [source]#
- Parameters:
- Raises:
ValueError, if package is specified for an __init__.py –
- reset_run_errors() None [source]#
Clears any transient error conditions from a previous run.
- Returns
None
- run(module: ModuleType, post_check: Callable[[], None] | None = None) None [source]#
Execute the configured source code in a module and run any post checks.
- Parameters:
module (Module) – A module to execute the configured code in.
post_check (callable, optional) – A function that raises an exception if expected post-conditions are not met after code execution.
- property error_detail: str | None#
If code execution fails, may contain a traceback or other details.
- property path: Union[str, os.PathLike[str]]#
The path that new modules will be configured with.