itkwidgets.cell_watcher
¶
Module Contents¶
Classes¶
This class is designed to track each instance of the Viewer class that is instantiated as well as whether or not that instance is available for updates or requests. |
|
A singleton class used in interactive Jupyter notebooks in order to support asynchronous network communication that would otherwise be blocked by the IPython kernel. |
Data¶
API¶
- itkwidgets.cell_watcher.background_tasks¶
‘set(…)’
- class itkwidgets.cell_watcher.Viewers¶
Bases:
object
This class is designed to track each instance of the Viewer class that is instantiated as well as whether or not that instance is available for updates or requests.
Initialization
- property not_created: List[str]¶
Return a list of all unavailable viewers
- Returns:
A list of names of viewers that have not yet been created.
- Return type:
List[str]
- add_viewer(view: str) None ¶
Add a new Viewer object to track.
- Parameters:
view (str) – The unique string identifier for the Viewer object
- class itkwidgets.cell_watcher.CellWatcher¶
Bases:
object
A singleton class used in interactive Jupyter notebooks in order to support asynchronous network communication that would otherwise be blocked by the IPython kernel.
- __new__()¶
Create a singleton class.
- setup() None ¶
Perform the initial setup, including intercepting ‘execute_request’ handlers so that we can handle them internally before the IPython kernel does.
- add_viewer(view: str) None ¶
Add a new Viewer object to track.
- Parameters:
view (str) – The unique string identifier for the Viewer object
- update_viewer_status(view: str, status: bool) None ¶
Update a Viewer’s ‘ready’ status. If the last cell run failed because the viewer was unavailable try to run the cell again.
- _task_cleanup(task: asyncio.Task) None ¶
Callback to discard references to tasks once they’ve completed.
- Parameters:
task (asyncio.Task) – Completed task that no longer needs a strong reference
- create_task(fn: Callable) None ¶
Create a task from the function passed in.
- Parameters:
fn (Callable) – Coroutine to run concurrently as a Task
- capture_event(stream: zmq.eventloop.zmqstream.ZMQStream, ident: list, parent: dict) None ¶
Capture execute_request messages so that we can queue and process them concurrently as tasks to prevent blocking.
- async capture_event_async(stream: zmq.eventloop.zmqstream.ZMQStream, ident: list, parent: dict) None ¶
Capture execute_request messages so that we can queue and process them concurrently as tasks to prevent blocking. Asynchronous for ipykernel 6+.
- property all_getters_resolved: bool¶
Determine if all tasks representing asynchronous network calls that fetch values have resolved.
- Returns:
Whether or not all tasks for the current cell have resolved
- Return type:
- ready_to_run_next_cell() bool ¶
Determine if we are ready to run the next cell in the queue.
- Returns:
If created Viewer objects are available and all futures are resolved.
- Return type:
- async execute_next_request() None ¶
Grab the next request if needed and then run the cell if it it ready to be run. Modeled after the approach used in jupyter-ui-poll.
- async _execute_next_request() None ¶
Run the cell with the ipykernel shell_handler for execute_request