import debug from "debug";1import { asyncPython } from "python-wasm";23// TODO: will get exported in future version of python-wasm.4type PythonWasmAsync = Awaited<ReturnType<typeof asyncPython>>;56const log = debug("python");78let python: PythonWasmAsync | null = null;910// todo: reuseInFlight...?11export default async function getPython() {12if (python == null) {13// Very important to explicitly set the fs, since that's not the default yet.14python = await asyncPython({ noStdio: true, fs: "everything" });15}16return python;17}1819export function pythonTerminate() {20if (python == null) return;21const kernel = python.kernel;22python = null;23kernel.terminate();24}252627