bokeh.application.handlers.code_runner

Provide a utility class CodeRunner for use by handlers that execute Python source code.

class CodeRunner(source, path, argv)[source]

Compile and run Python source code.

__init__(source, path, argv)[source]
Parameters:
  • source (str) – python source code
  • path (str) – a filename to use in any debugging or error output
  • argv (list[str]) – a list of string arguments to make available as sys.argv when the code executes
new_module()[source]

Make a fresh module to run in.

Returns:Module
reset_run_errors()[source]

Clears any transient error conditions from a previous run.

Returns
None
run(module, post_check)[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) – a function that can raise an exception if expected post-conditions are not met after code execution.
error

If code execution fails, may contain a related error message.

error_detail

If code execution fails, may contain a traceback or other details.

failed

True if code execution failed

path

The path that new modules will be configured with.

source

The configured source code that will be executed when run is called.