code: def connect_to_ipykernel(self, service_name, timeout=10):
          
          kernel_json_file = self.wait_for_ipykernel(service_name, timeout=10)
          self.start_interactive_mode()
          subprocess.check_call([
              sys.executable, "-m", "IPython", "console", "--existing", kernel_json_file
          ])
          self.stop_interactive_mode()
docs: Connect to an IPython kernel as soon as its message is logged.