Class PythonAsyncioRuntime
java.lang.Object
io.micronaut.context.python.PythonAsyncioRuntime
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCompletes futures with Java exceptions from Python exception data.static final classRunsasyncio.run_in_executor(None, ...)callbacks on Micronaut's blocking executor.static final classCompletableFuture variant that can propagate Java cancellation to a Python task. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidsetEnabled(boolean enabled) Set whether Python asyncio bridge execution is enabled.static org.graalvm.polyglot.ValuetoAwaitable(org.graalvm.polyglot.Context context, CompletionStage<?> stage) Wrap a JavaCompletionStageas an asyncio future for Pythonawait.static CompletionStagetoCompletionStage(org.graalvm.polyglot.Value value) Convert a Python coroutine or awaitable value into a JavaCompletionStage.
-
Method Details
-
toCompletionStage
Convert a Python coroutine or awaitable value into a JavaCompletionStage.- Parameters:
value- The Python result value.- Returns:
- A stage that completes when the Python awaitable completes.
-
toAwaitable
public static org.graalvm.polyglot.Value toAwaitable(org.graalvm.polyglot.Context context, CompletionStage<?> stage) Wrap a JavaCompletionStageas an asyncio future for Pythonawait.- Parameters:
context- The Python context.stage- The Java completion stage.- Returns:
- An asyncio future.
-
setEnabled
public static void setEnabled(boolean enabled) Set whether Python asyncio bridge execution is enabled.- Parameters:
enabled- Whether async bridge execution is enabled.
-