PythonWorker

Python Worker Message Handler Executes Python code blocks using Pyodide (WebAssembly Python).

Workflow:

  1. Receives execution context (code, dependencies, settings).
  2. Initializes Pyodide and auto-loads required packages.
  3. Resolves data dependencies from IndexedDB.
  4. Converts JavaScript data to Python-compatible formats (Lists, Dicts, NumPy arrays).
  5. Binds data to the Python global scope as data.
  6. Wraps and executes the user's Python code, capturing stdout/stderr.
  7. Converts the Python result back to JavaScript.
  8. Stores the result in IndexedDB and sends completion status.
Source: