jupyter_ui_poll.ui_events

jupyter_ui_poll.ui_events()[source]

Gives you a function you can call to process UI events while running a long task inside a Jupyter cell.

with ui_events() as ui_poll:
   while some_condition:
      ui_poll(10)  # Process upto 10 UI events if any happened
      do_some_more_compute()

Async mode is also supported:

async with ui_events() as ui_poll:
   while some_condition:
      await ui_poll(10)  # Process upto 10 UI events if any happened
      do_some_more_compute()
  1. Call kernel.do_one_iteration() taking care of IO redirects

  2. Intercept execute_request IPython kernel events and delay their execution

  3. Schedule replay of any blocked execute_request events when cell execution is finished.