Skip to content

Commit 009abf4

Browse files
authoredSep 26, 2023
Increase asyncify stack size (#106)
Pick the first power of two where we fail with a pystack exhausted error in MicroPython rather than an asyncify-related error. Add an example to the demo that finds the max stack size.
1 parent 5e619dd commit 009abf4

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed
 

‎src/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ COPT += -O3 -DNDEBUG
4444
endif
4545

4646
JSFLAGS += -s ASYNCIFY
47+
# We can hit lower values due to user stack use. See stack_size.py example.
48+
JSFLAGS += -s ASYNCIFY_STACK_SIZE=262144
4749
JSFLAGS += -s EXIT_RUNTIME
4850
JSFLAGS += -s MODULARIZE=1
4951
JSFLAGS += -s EXPORT_NAME=createModule

‎src/demo.html

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ <h1>MicroPython-micro:bit simulator example embedding</h1>
100100
</option>
101101
<option value="sound_effects_user">Sound effects (user)</option>
102102
<option value="speech">Speech</option>
103+
<option value="stack_size">Stack size</option>
103104
<option value="volume">Volume</option>
104105
</select>
105106
<textarea

‎src/examples/stack_size.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def g():
2+
global depth
3+
depth += 1
4+
g()
5+
depth = 0
6+
try:
7+
g()
8+
except RuntimeError:
9+
pass
10+
print('maximum recursion depth g():', depth)

0 commit comments

Comments
 (0)