diff --git a/ipykernel/kernelbase.py b/ipykernel/kernelbase.py index 2b5b63e5..7c65ef2c 100644 --- a/ipykernel/kernelbase.py +++ b/ipykernel/kernelbase.py @@ -551,7 +551,9 @@ async def start(self, *, task_status: TaskStatus = TASK_STATUS_IGNORED) -> None: # Assign tasks to and start shell channel thread. manager = self.shell_channel_thread.manager self.shell_channel_thread.add_task(self.shell_channel_thread_main) - self.shell_channel_thread.add_task(manager.listen_from_control, self.shell_main, self.shell_channel_thread) + self.shell_channel_thread.add_task( + manager.listen_from_control, self.shell_main, self.shell_channel_thread + ) self.shell_channel_thread.add_task(manager.listen_from_subshells) self.shell_channel_thread.start() else: @@ -1081,7 +1083,9 @@ async def create_subshell_request(self, socket, ident, parent) -> None: # This should only be called in the control thread if it exists. # Request is passed to shell channel thread to process. - other_socket = await self.shell_channel_thread.manager.get_control_other_socket(self.control_thread.get_task_group()) + other_socket = await self.shell_channel_thread.manager.get_control_other_socket( + self.control_thread.get_task_group() + ) await other_socket.asend_json({"type": "create"}) reply = await other_socket.arecv_json() @@ -1103,7 +1107,9 @@ async def delete_subshell_request(self, socket, ident, parent) -> None: # This should only be called in the control thread if it exists. # Request is passed to shell channel thread to process. - other_socket = await self.shell_channel_thread.manager.get_control_other_socket(self.control_thread.get_task_group()) + other_socket = await self.shell_channel_thread.manager.get_control_other_socket( + self.control_thread.get_task_group() + ) await other_socket.asend_json({"type": "delete", "subshell_id": subshell_id}) reply = await other_socket.arecv_json() @@ -1118,7 +1124,9 @@ async def list_subshell_request(self, socket, ident, parent) -> None: # This should only be called in the control thread if it exists. # Request is passed to shell channel thread to process. - other_socket = await self.shell_channel_thread.manager.get_control_other_socket(self.control_thread.get_task_group()) + other_socket = await self.shell_channel_thread.manager.get_control_other_socket( + self.control_thread.get_task_group() + ) await other_socket.asend_json({"type": "list"}) reply = await other_socket.arecv_json() diff --git a/ipykernel/subshell_manager.py b/ipykernel/subshell_manager.py index 46832c99..66e31fd8 100644 --- a/ipykernel/subshell_manager.py +++ b/ipykernel/subshell_manager.py @@ -40,7 +40,12 @@ class SubshellManager: against multiple subshells attempting to send at the same time. """ - def __init__(self, context: zmq.Context, shell_socket: zmq_anyio.Socket, get_task_group: Callable[[], TaskGroup]): + def __init__( + self, + context: zmq.Context, + shell_socket: zmq_anyio.Socket, + get_task_group: Callable[[], TaskGroup], + ): assert current_thread() == main_thread() self._context: zmq.Context = context @@ -229,7 +234,9 @@ def _is_subshell(self, subshell_id: str | None) -> bool: with self._lock_cache: return subshell_id in self._cache - async def _listen_for_subshell_reply(self, subshell_id: str | None, task_group: TaskGroup) -> None: + async def _listen_for_subshell_reply( + self, subshell_id: str | None, task_group: TaskGroup + ) -> None: """Listen for reply messages on specified subshell inproc socket and resend to the client via the shell_socket. diff --git a/tests/conftest.py b/tests/conftest.py index dfa7df5d..c981f867 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,10 +22,11 @@ resource = None # type:ignore -@pytest.fixture +@pytest.fixture() def anyio_backend(): return "asyncio" + pytestmark = pytest.mark.anyio