Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure KernelClient's API is complete #794

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions jupyter_client/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from threading import Event
from threading import Thread

import zmq.asyncio
import zmq
from zmq.asyncio import Context
from zmq.asyncio import Socket

from .channelsabc import HBChannelABC
from .session import Session
Expand Down Expand Up @@ -49,7 +51,7 @@ class HBChannel(Thread):

def __init__(
self,
context: t.Optional[zmq.asyncio.Context] = None,
context: t.Optional[Context] = None,
session: t.Optional[Session] = None,
address: t.Union[t.Tuple[str, int], str] = "",
):
Expand Down Expand Up @@ -193,7 +195,7 @@ def call_handlers(self, since_last_heartbeat: float) -> None:
class ZMQSocketChannel(object):
"""A ZMQ socket in an async API"""

def __init__(self, socket: zmq.asyncio.Socket, session: Session, loop: t.Any = None) -> None:
def __init__(self, socket: Socket, session: Session, loop: t.Any = None) -> None:
"""Create a channel.

Parameters
Expand All @@ -207,7 +209,7 @@ def __init__(self, socket: zmq.asyncio.Socket, session: Session, loop: t.Any = N
"""
super().__init__()

self.socket: t.Optional[zmq.asyncio.Socket] = socket
self.socket: t.Optional[Socket] = socket
self.session = session

async def _recv(self, **kwargs: t.Any) -> t.Dict[str, t.Any]:
Expand Down
20 changes: 20 additions & 0 deletions jupyter_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ class KernelClient(ConnectionFileMixin):
:meth:`get_shell_msg` to fetch messages from the shell channel.
"""

get_shell_msg: t.Callable[
..., t.Union[t.Coroutine[t.Any, t.Any, t.Dict[str, t.Any]], t.Dict[str, t.Any]]
]
get_iopub_msg: t.Callable[
..., t.Union[t.Coroutine[t.Any, t.Any, t.Dict[str, t.Any]], t.Dict[str, t.Any]]
]
get_stdin_msg: t.Callable[
..., t.Union[t.Coroutine[t.Any, t.Any, t.Dict[str, t.Any]], t.Dict[str, t.Any]]
]
get_control_msg: t.Callable[
..., t.Union[t.Coroutine[t.Any, t.Any, t.Dict[str, t.Any]], t.Dict[str, t.Any]]
]
wait_for_ready: t.Callable[
["KernelClient", t.Optional[float]], t.Union[t.Coroutine[t.Any, t.Any, None], None]
]
is_alive: t.Callable[["KernelClient"], t.Union[t.Coroutine[t.Any, t.Any, bool], bool]]
execute_interactive: t.Callable[
..., t.Union[t.Coroutine[t.Any, t.Any, t.Dict[str, t.Any]], t.Dict[str, t.Any]]
]

# The PyZMQ Context to use for communication with the kernel.
context = Instance(zmq.asyncio.Context)

Expand Down