PiotrDabkowski / Js2Py

JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python🚀 Try it online:
http://piter.io/projects/js2py
MIT License
2.47k stars 261 forks source link

how to call async func in pycode called by js #239

Closed RonaldinhoL closed 3 years ago

RonaldinhoL commented 3 years ago

my code like:

def pyfunc():
    ~~~i want here call another_async_func ~~~

async def another_async_func():
    pass

async def main():
    ctx = js2py.EvalJS()
    ctx.pyfunc = pyfunc
    ctx.eval("""pyfunc()""")

asyncio.run(main())
RonaldinhoL commented 3 years ago

i found pyfunc set to ctx can not be a coroutines , than i try get_event_loop in pyfunc(), it can not work either.

RonaldinhoL commented 3 years ago

solved.

psytron commented 3 years ago

solved.

Share solution?