Class PythonAsyncioStreams.GeneratorSubscription
java.lang.Object
io.micronaut.context.python.PythonAsyncioStreams.GeneratorSubscription
- All Implemented Interfaces:
Subscription
- Enclosing class:
PythonAsyncioStreams
@Internal
public static final class PythonAsyncioStreams.GeneratorSubscription
extends Object
implements Subscription
The subscription handed to a Java subscriber of a Python async iterator, and the facade the
Python driver signals through.
Demand and cancellation travel to the driver on the loop; the driver advances the iterator
only with positive demand and reports elements, the error or the completion back through
next(Value), error(Value) and complete(). A terminal signal is emitted at most
once, and no element after it. The stream counts as an active execution of its context from
the subscription until the driver has released the iterator, so a graceful shutdown waits
for the generator's cleanup.
- Since:
- 5.2.3
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()voidcomplete()Python entry point: the iterator is exhausted.voiderror(org.graalvm.polyglot.Value exception) Python entry point: the iterator raised.booleanisDone()voidnext(org.graalvm.polyglot.Value item) Python entry point: an element the iterator produced.voidreleased()Python entry point: the iterator has been closed, nothing of the stream runs any more.voidrequest(long n)
-
Method Details
-
request
public void request(long n) - Specified by:
requestin interfaceSubscription
-
cancel
public void cancel()- Specified by:
cancelin interfaceSubscription
-
next
public void next(org.graalvm.polyglot.Value item) Python entry point: an element the iterator produced.- Parameters:
item- The element, never None
-
error
public void error(org.graalvm.polyglot.Value exception) Python entry point: the iterator raised.- Parameters:
exception- The Python exception, or a Java throwable
-
complete
public void complete()Python entry point: the iterator is exhausted. -
released
public void released()Python entry point: the iterator has been closed, nothing of the stream runs any more. -
isDone
public boolean isDone()- Returns:
- Whether the subscriber cancelled or a terminal signal was emitted
-