brython/manager/executor.js - Brython Executor
Location: src/brython/manager/executor.js
This file is responsible for the actual execution of Python code using the Brython engine.
Function: executeAsync(code, filename)
- Description: This function takes a string of Python code, wraps it in a boilerplate that redirects
stdoutandstderrand defines amissivefunction, and then executes it. It achieves this by creating a new<script type="text/python3">tag, adding the code to it, and appending it to the document. Brython then automatically discovers and runs the code. - Parameters:
code(string): The Python code to execute.filename(string, default:'script.py'): A name for the execution.
- Returns: A
Promisethat resolves with an object containing thestdout,stderr,missive, and executiontime. - Throws:
Errorif the Brython runtime is not initialized.