jupyter_ui_poll.with_ui_events

jupyter_ui_poll.with_ui_events(its, n=1)[source]

Deal with kernel ui events while processing a long sequence

Iterable returned from this can be used in both async and sync contexts.

for x in with_ui_events(some_data_stream, n=10):
   do_things_with(x)

async for x in with_ui_events(some_data_stream, n=10):
   await do_things_with(x)

This is basically equivalent to:

with ui_events() as poll:
  for x in some_data_stream:
      poll(10)
      do_things_with(x)
Parameters
  • its – Iterator to pass through, this should be either Iterable or AsyncIterable

  • n (int) – Number of events to process in between items

Returns

AsyncIterable when input is AsyncIterable

Returns

Object that implements both Iterable and AsyncIterable interfaces when input is normal Iterable