From 6afd86738000409c3ba2149391a87d383c03c40b Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Fri, 30 Jan 2026 10:56:07 +0100 Subject: [PATCH 1/2] Made IOPubThread constructor backward compatible --- ipykernel/inprocess/ipkernel.py | 2 +- ipykernel/iostream.py | 4 ++-- ipykernel/kernelapp.py | 2 +- tests/test_io.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ipykernel/inprocess/ipkernel.py b/ipykernel/inprocess/ipkernel.py index 7ed47443b..c62295044 100644 --- a/ipykernel/inprocess/ipkernel.py +++ b/ipykernel/inprocess/ipkernel.py @@ -56,7 +56,7 @@ class InProcessKernel(IPythonKernel): @default("iopub_thread") def _default_iopub_thread(self): - thread = IOPubThread(self._underlying_iopub_socket, self.session) + thread = IOPubThread(self._underlying_iopub_socket, session = self.session) thread.start() return thread diff --git a/ipykernel/iostream.py b/ipykernel/iostream.py index a426139ed..cc15018ee 100644 --- a/ipykernel/iostream.py +++ b/ipykernel/iostream.py @@ -47,7 +47,7 @@ class IOPubThread: whose IO is always run in a thread. """ - def __init__(self, socket, session=None, pipe=False): + def __init__(self, socket, pipe=False, session=False): """Create IOPub thread Parameters @@ -518,7 +518,7 @@ def __init__( DeprecationWarning, stacklevel=2, ) - pub_thread = IOPubThread(pub_thread, self.session) + pub_thread = IOPubThread(pub_thread, session = self.session) pub_thread.start() self.pub_thread = pub_thread self.name = name diff --git a/ipykernel/kernelapp.py b/ipykernel/kernelapp.py index a450d6ca7..9a6d2c6fc 100644 --- a/ipykernel/kernelapp.py +++ b/ipykernel/kernelapp.py @@ -382,7 +382,7 @@ def init_iopub(self, context): self.iopub_port = self._bind_socket(self.iopub_socket, self.iopub_port) self.log.debug("iopub PUB Channel on port: %i", self.iopub_port) self.configure_tornado_logger() - self.iopub_thread = IOPubThread(self.iopub_socket, self.session, pipe=True) + self.iopub_thread = IOPubThread(self.iopub_socket, pipe=True, session = self.session) self.iopub_thread.start() # backward-compat: wrap iopub socket API in background thread self.iopub_socket = self.iopub_thread.background_socket diff --git a/tests/test_io.py b/tests/test_io.py index da1000f4e..217680a4f 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -28,7 +28,7 @@ def ctx(): def iopub_thread(ctx): session = Session() with ctx.socket(zmq.PUB) as pub: - thread = IOPubThread(pub, session) + thread = IOPubThread(pub, session=session) thread.start() yield thread @@ -156,7 +156,7 @@ def subprocess_test_echo_watch(): # use PUSH socket to avoid subscription issues with zmq.Context() as ctx, ctx.socket(zmq.PUSH) as pub: pub.connect(os.environ["IOPUB_URL"]) - iopub_thread = IOPubThread(pub, session) + iopub_thread = IOPubThread(pub, session=session) iopub_thread.start() stdout_fd = sys.stdout.fileno() sys.stdout.flush() From d0c9d20dfcba54c4a59f12c837c9b400ce9913cc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 09:58:53 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ipykernel/inprocess/ipkernel.py | 2 +- ipykernel/iostream.py | 2 +- ipykernel/kernelapp.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ipykernel/inprocess/ipkernel.py b/ipykernel/inprocess/ipkernel.py index c62295044..e61af4277 100644 --- a/ipykernel/inprocess/ipkernel.py +++ b/ipykernel/inprocess/ipkernel.py @@ -56,7 +56,7 @@ class InProcessKernel(IPythonKernel): @default("iopub_thread") def _default_iopub_thread(self): - thread = IOPubThread(self._underlying_iopub_socket, session = self.session) + thread = IOPubThread(self._underlying_iopub_socket, session=self.session) thread.start() return thread diff --git a/ipykernel/iostream.py b/ipykernel/iostream.py index cc15018ee..33213d167 100644 --- a/ipykernel/iostream.py +++ b/ipykernel/iostream.py @@ -518,7 +518,7 @@ def __init__( DeprecationWarning, stacklevel=2, ) - pub_thread = IOPubThread(pub_thread, session = self.session) + pub_thread = IOPubThread(pub_thread, session=self.session) pub_thread.start() self.pub_thread = pub_thread self.name = name diff --git a/ipykernel/kernelapp.py b/ipykernel/kernelapp.py index 9a6d2c6fc..b2f614ea9 100644 --- a/ipykernel/kernelapp.py +++ b/ipykernel/kernelapp.py @@ -382,7 +382,7 @@ def init_iopub(self, context): self.iopub_port = self._bind_socket(self.iopub_socket, self.iopub_port) self.log.debug("iopub PUB Channel on port: %i", self.iopub_port) self.configure_tornado_logger() - self.iopub_thread = IOPubThread(self.iopub_socket, pipe=True, session = self.session) + self.iopub_thread = IOPubThread(self.iopub_socket, pipe=True, session=self.session) self.iopub_thread.start() # backward-compat: wrap iopub socket API in background thread self.iopub_socket = self.iopub_thread.background_socket