Class PythonAsyncioStreams.PublisherIterator

java.lang.Object
io.micronaut.context.python.PythonAsyncioStreams.PublisherIterator
All Implemented Interfaces:
Subscriber<Object>
Enclosing class:
PythonAsyncioStreams

@Internal public static final class PythonAsyncioStreams.PublisherIterator extends Object implements Subscriber<Object>
Subscribes to a publisher one item at a time on behalf of a Python async iterator.

The subscription is lazy: the first request() subscribes. Every request asks for one item; requests made before onSubscribe arrives are accumulated. Signals reach the Python callbacks through PythonAsyncioStreams.dispatch(PythonEventLoop, Context, Runnable, Runnable), and once the context refuses the frame (it is closing) the subscription is cancelled so no further signals are attempted.

Since:
5.2.3
  • Method Details

    • request

      public void request()
      Request one more item, subscribing first when this is the first request.
    • cancel

      public void cancel()
      Cancel the subscription; later signals are ignored. Idempotent.
    • isCancelled

      public boolean isCancelled()
      Returns:
      Whether the subscription was cancelled from the Python side
    • onSubscribe

      public void onSubscribe(Subscription subscription)
      Specified by:
      onSubscribe in interface Subscriber<Object>
    • onNext

      public void onNext(Object item)
      Specified by:
      onNext in interface Subscriber<Object>
    • onError

      public void onError(Throwable throwable)
      Specified by:
      onError in interface Subscriber<Object>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface Subscriber<Object>