Open psytron opened 3 years ago
please, that would be so helpful!
Is there any possibility to run async function? I am getting a syntax error
This depends on ES6 Promise support before it can be added: https://github.com/PiotrDabkowski/Js2Py/issues/273
The await keyword looks like it's blocking, so we'd probably need to implement threading for it to work.
This depends on ES6 Promise support before it can be added: #273
The await keyword looks like it's blocking, so we'd probably need to implement threading for it to work.
Can We help you somehow with it, to make that happen?
I suppose by becoming so motivated to get your code running that you pull up the specifications and produce patches to try and implement those features. Threading in particular is a huge open question for me. I have so far put off any effort in researching it personally.
I have looked into adding Promise support, but none of the code I want to run uses it. Makes investing time into it a tough sell, especially given that it's more or less out-of-scope for an ecmascript 5.1 interpreter.
example: sleep should be translated to asyncio.sleep
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function main() {
await sleep(100);
}
main();
import asyncio
async def main():
await asyncio.sleep(0.1)
asyncio.run(main())
How to enable async await?