Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Feb 18, 2024
1 parent 2ac544f commit 1cd1235
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
36 changes: 36 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Migration Guide

## Jupyter Client 8.0 to 9.0

Overall changes: removed direct usages of `tornado` in favor of `asyncio` loops.
We are still using `zmq.eventloop.zmqstream.ZMQStream`, which uses `tornado`
loops internally.

### API Changes

The following `loop` properties are now asyncio loops:

- `jupyter_client.ioloop.manager.IOLoopKernelManager.loop`
- `jupyter_client.ioloop.manager.AsyncIOLoopKernelManager.loop`
- `jupyter_client.ioloop.restarter.IOLoopKernelRestarter.loop`
- `jupyter_client.ioloop.restarter.AsyncIOLoopKernelRestarter.loop`
- `jupyter_client.threaded.ThreadedZMQSocketChannel.loop`
- `jupyter_client.threaded.IOLoopThread.ioloop`
- `jupyter_client.threaded.ThreadedKernelClient.ioloop`

The `jupyter_client.kernelapp.KernelApp` class now subclasses
`jupyter_core.application.JupyterAsyncApp`, and performs its initialization
from within an asyncio loop.

The following function was added as a shim to the `jupyter_core` utility:

- `jupyter_client.utils.ensure_event_loop`

## Jupyter Client 7.0 to 8.0

The main goal of this release was to improve handling of asyncio and remove
the need for `nest_asyncio`.

### API Changes

- `jupyter_client.asynchronous.client.AsyncKernelClient.context` is now a `zmq.asyncio.Context`
- `jupyter_client.asynchronous.client.AsyncKernelClient.*_channel_class` are now instances of `jupyter_client.channels.AsyncZMQSocketChannel`

## Jupyter Client 6.0 to 7.0

### API Changes
Expand Down
8 changes: 7 additions & 1 deletion jupyter_client/ioloop/restarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import asyncio
import time

from jupyter_core.utils import ensure_async
from jupyter_core.utils import ensure_async, ensure_event_loop
from traitlets import Instance

from ..restarter import KernelRestarter

Expand All @@ -21,6 +22,11 @@ class IOLoopKernelRestarter(KernelRestarter):
_poll_task: asyncio.Task | None = None
_running = False

loop = Instance(asyncio.AbstractEventLoop) # type:ignore[type-abstract]

def _loop_default(self) -> asyncio.AbstractEventLoop:
return ensure_event_loop()

def start(self) -> None:
"""Start the polling of the kernel."""
if not self._poll_task:
Expand Down
4 changes: 4 additions & 0 deletions jupyter_client/threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def close(self) -> None:
msg = f"Error closing socket {self.socket}: {e}"
log.warning(msg, RuntimeWarning, stacklevel=2)

def flush(self):
"""Flush the channel."""
pass

def _thread_close(self) -> None:
if self.socket is None:
return
Expand Down
1 change: 1 addition & 0 deletions tests/test_multikernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ async def test_bad_kernelspec_pending(self):
await ensure_future(km.shutdown_kernel(kernel_id))
assert kernel_id not in km.list_kernel_ids()

@skip_win32
async def test_stream_on_recv(self):
mkm = self._get_tcp_km()
kid = await mkm.start_kernel(stdout=PIPE, stderr=PIPE)
Expand Down

0 comments on commit 1cd1235

Please sign in to comment.