mirror of https://github.com/pyodide/pyodide.git
Added "globals" as a 2nd param to runPythonAsync (#1914)
This commit is contained in:
parent
966714a48d
commit
4042db2615
|
@ -176,11 +176,14 @@ export async function loadPackagesFromImports(
|
||||||
* console.log(result); // 79
|
* console.log(result); // 79
|
||||||
*
|
*
|
||||||
* @param {string} code Python code to evaluate
|
* @param {string} code Python code to evaluate
|
||||||
|
* @param {PyProxy} globals An optional Python dictionary to use as the globals.
|
||||||
|
* Defaults to :any:`pyodide.globals`. Uses the Python API
|
||||||
|
* :any:`pyodide.eval_code_async` to evaluate the code.
|
||||||
* @returns {Py2JsResult} The result of the Python code translated to JavaScript.
|
* @returns {Py2JsResult} The result of the Python code translated to JavaScript.
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
export async function runPythonAsync(code) {
|
export async function runPythonAsync(code, globals = Module.globals) {
|
||||||
let coroutine = Module.pyodide_py.eval_code_async(code, Module.globals);
|
let coroutine = Module.pyodide_py.eval_code_async(code, globals);
|
||||||
try {
|
try {
|
||||||
return await coroutine;
|
return await coroutine;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue