FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

webprompt: better support for asyncify testing · python-emscripten/python@bd7b311 · GitHub

Repository navigation

Commit bd7b311

Browse files
me
committed
webprompt: better support for asyncify testing
1 parent 7b269d6 commit bd7b311

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

‎2.7.10/webprompt-shell.html‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@
166166
if (!ready) { Module.print('Python is loading, please wait...'); return; }
167167
Module.print('>>> <textarea>');
168168
source_code = document.getElementById('file').value;
169-
Module.cwrap('PyRun_SimpleString', 'number', ['string'])(source_code);
170-
// or: Module.ccall('PyRun_SimpleString', 'number', ['string'], [source_code]);
169+
var opts = {}
170+
if (typeof Asyncify === 'object')
171+
opts = { async: true };
172+
Module.cwrap('PyRun_SimpleString', 'number', ['string'], opts)(source_code);
173+
// or: Module.ccall('PyRun_SimpleString', 'number', ['string'], [source_code], opts);
171174
}
172175

173176
var hist = [''];
@@ -179,8 +182,11 @@
179182
Module.print('>>> ' + input.value);
180183

181184
// Execute Python code with emulated stdin
182-
FS.writeFile('/tmp/input.py', input.value + '\n')
183-
Module.ccall('pyruni');
185+
FS.writeFile('/tmp/input.py', input.value + '\n');
186+
var opts = {}
187+
if (typeof Asyncify === 'object')
188+
opts = { async: true };
189+
Module.ccall('pyruni', 'undefined', [], [], opts);
184190

185191
hist[hist.length-1] = input.value;
186192
hist.push('');

‎2.7.10/webprompt.sh‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ PREFIX=$INSTALLDIR OUTDIR=$BUILD ./package-pythonhome.sh \
2323
encodings/utf_32_be.py
2424

2525
FLAGS='-O3'
26-
if [ "$1" == "debug" ]; then
27-
FLAGS='-s ASSERTIONS=1 -g -s FETCH_DEBUG=1'
28-
fi
26+
while (( $# )); do
27+
case "$1" in
28+
debug) FLAGS='-s ASSERTIONS=1 -g -s FETCH_DEBUG=1';;
29+
async) ASYNC='-s ASYNCIFY=1 -O3';;
30+
esac
31+
shift
32+
done
2933
emcc -o $BUILD/index.html \
3034
webprompt-main.c $BUILD/emscripten.c \
3135
$FLAGS \
@@ -35,10 +39,10 @@ emcc -o $BUILD/index.html \
3539
-s FETCH=1 \
3640
-s ALLOW_MEMORY_GROWTH=1 \
3741
-s FORCE_FILESYSTEM=1 -s RETAIN_COMPILER_SETTINGS=1 \
42+
$ASYNC \
3843
--shell-file webprompt-shell.html -s MINIFY_HTML=0 \
39-
-s EXPORTED_FUNCTIONS="['_main', '_Py_Initialize', '_PyRun_SimpleString', '_pyruni']" \
40-
-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'
41-
# -s ASYNCIFY=1
44+
-s EXPORTED_FUNCTIONS='[_main, _Py_Initialize, _PyRun_SimpleString, _pyruni, _emscripten_debugger]' \
45+
-s EXTRA_EXPORTED_RUNTIME_METHODS='[ccall, cwrap]'
4246

4347
# cython ../mock/emscripten.pyx -o t/mock.c
4448
# gcc -g -I build/hostpython/include/python2.7 -L build/hostpython/lib/ t/mock.c webprompt-main.c -lpython2.7 -ldl -lm -lutil -lz

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL