Replies: 1 comment
-
|
The thing I understood so far, is that "It is safe to use a context instance from a single thread. It is also safe to use it with multiple threads if they do not access the context at the same time.". So basically I'm trying to make access to context through the same 1 thread throughout the program. HOWEVER when this works in JS: With top-level await, the result is gotten immediately as pending promise (top-level) and the event loop is freed so that other promises can get resolved, but in Python, similar code does not even work, because context.eval on top-level code that called asyncio.run, blocks the whole of the event loop, making it impossible to resolve inner futures which are prerequisite to resolving the top-level one... it's basically a dead-lock, which does not happen in JS because context.eval returns a promise. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
For GraalJS, there's a section on Promises in the documentation:
So I've tried similar with Python, given a script
and an adapter:
In Java, we create a future:
With the Java-based APIs:
I've spent an entire weekend hacking and it just gives inconsistent results... Sometime it run, other times it doesn't... When the promise is resolved on the same tick (during debug, returning an already finished future), it's fine but it's pending first, it stops working
but when the promise is pending initially, it gets stuck
Is there more docs on futures and how i can return promised returns from my java infra?
Beta Was this translation helpful? Give feedback.
All reactions