Skip to content

Commit

Permalink
Fix stdin ZMQ channel
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Apr 7, 2022
1 parent b07bbd2 commit f81f481
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, ConnectionFileMix
heartbeat = Instance(Heartbeat, allow_none=True)

context = Any()
sync_context = Any()
shell_socket = Any()
control_socket = Any()
debugpy_socket = Any()
Expand Down Expand Up @@ -304,14 +305,15 @@ def init_sockets(self):
self.log.info("Starting the kernel at pid: %i", os.getpid())
assert self.context is None, "init_sockets cannot be called twice!"
self.context = context = zmq.asyncio.Context()
self.sync_context = sync_context = zmq.Context()
atexit.register(self.close)

self.shell_socket = context.socket(zmq.ROUTER)
self.shell_socket.linger = 1000
self.shell_port = self._bind_socket(self.shell_socket, self.shell_port)
self.log.debug("shell ROUTER Channel on port: %i" % self.shell_port)

self.stdin_socket = context.socket(zmq.ROUTER)
self.stdin_socket = sync_context.socket(zmq.ROUTER)
self.stdin_socket.linger = 1000
self.stdin_port = self._bind_socket(self.stdin_socket, self.stdin_port)
self.log.debug("stdin ROUTER Channel on port: %i" % self.stdin_port)
Expand Down Expand Up @@ -397,6 +399,7 @@ def close(self):
self.log.debug("Terminating zmq context")
# FIXME: this line breaks shutdown
# self.context.term()
self.sync_context.term()
self.log.debug("Terminated zmq context")

def log_connection_info(self):
Expand Down

0 comments on commit f81f481

Please sign in to comment.