tbodt / v8py

Write Python APIs, then call them from JavaScript using the V8 engine.
GNU Lesser General Public License v3.0
440 stars 28 forks source link

Added Promise support #19

Closed desertkun closed 6 years ago

desertkun commented 6 years ago

So async/await can be handled by python and used in asynchronous frameworks.

async function test()
{
    await sleep(..)
    return 5;
}

When async function is called, Javascript returns Promise. This commit adds a way to detect one reliably:

from v8py import JSPromise

result = context.glob.test()
if isinstance(result, JSPromise):
    pass # this function is async, handle it async-way
tbodt commented 6 years ago

async is the FUTURE!

(maybe)