forked from sqreen/PyMiniRacer
-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
Steps to reproduce
>>> import py_mini_racer
>>> context = py_mini_racer.MiniRacer()
>>> result = context.eval("""
... async function pretendToDelay() {
... return new Promise(resolve => {
... setTimeout(() => resolve('Data loaded!'), 1000);
... });
... }
... pretendToDelay();
... """)
>>> print(result, result.__dict__)
<py_mini_racer.py_mini_racer.JSObject object at 0x100ec6620> {'id': 965435}That code to paste:
import py_mini_racer
context = py_mini_racer.MiniRacer()
result = context.eval("""
async function pretendToDelay() {
return new Promise(resolve => {
setTimeout(() => resolve('Data loaded!'), 1000);
});
}
pretendToDelay();
""")
print(result, result.__dict__)I tried using await pretendToDelay(); on the last line instead and got this:
py_mini_racer.py_mini_racer.JSParseException: SyntaxError: await is only valid in async functions and the top level bodies of modules
Expected behavior
I'm trying to figure out how to return the result from resolving that promise.
Assuming there's a pattern for doing this, it would be great if the test suite and documentation described it!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels