From 6afbaa45fc8eb0fa1965560267d9cba54f1ab47c Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 23 Jul 2021 15:03:05 +0000 Subject: [PATCH] Increase recursion limit (#1733) --- src/core/main.c | 7 +++++++ src/js/pyodide.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/main.c b/src/core/main.c index 7e836dab3..9c4654f5e 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -94,6 +94,13 @@ run_python_simple_inner(char* code) int numpy_patch_init(); +int +get_python_stack_depth() +{ + PyThreadState* tstate = PyThreadState_GET(); + return tstate->recursion_depth; +} + /** * Bootstrap steps here: * 1. Initialize init_dict so that runPythonSimple will work. diff --git a/src/js/pyodide.js b/src/js/pyodide.js index bb57ace83..914f2a80b 100644 --- a/src/js/pyodide.js +++ b/src/js/pyodide.js @@ -154,7 +154,7 @@ function fixRecursionLimit() { recurse(); } catch (err) {} - let recursionLimit = Math.min(depth / 50, 400); + let recursionLimit = Math.min(depth / 25, 500); Module.runPythonSimple( `import sys; sys.setrecursionlimit(int(${recursionLimit}))` );