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 Type
    Method
    Description
    void
     
    void
    Python entry point: the iterator is exhausted.
    void
    error(org.graalvm.polyglot.Value exception)
    Python entry point: the iterator raised.
    boolean
     
    void
    next(org.graalvm.polyglot.Value item)
    Python entry point: an element the iterator produced.
    void
    Python entry point: the iterator has been closed, nothing of the stream runs any more.
    void
    request(long n)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • request

      public void request(long n)
      Specified by:
      request in interface Subscription
    • cancel

      public void cancel()
      Specified by:
      cancel in interface Subscription
    • 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