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

PR: Add command line option to connect to an existing kernel at startup (IPython console) #23444

Merged
merged 9 commits into from
Jan 15, 2025
7 changes: 7 additions & 0 deletions spyder/app/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ def get_options(argv=None):
default=None,
help="Choose a configuration directory to use for Spyder."
)
parser.add_argument(
'--connect-to-kernel',
type=str,
dest="connection_file",
default=None,
help="Start Spyder and connect to an existing ipython kernel."
Social-Mean marked this conversation as resolved.
Show resolved Hide resolved
)

parser.add_argument('files', nargs='*')
options = parser.parse_args(argv)
Expand Down
7 changes: 6 additions & 1 deletion spyder/plugins/ipythonconsole/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,12 @@ def on_close(self, cancelable=False):
return self.get_widget().close_all_clients()

def on_mainwindow_visible(self):
self.create_new_client(give_focus=False)
cli_options = self.get_command_line_options()
connection_file = cli_options.connection_file
if connection_file is not None:
self.create_client_for_kernel(connection_file)
Social-Mean marked this conversation as resolved.
Show resolved Hide resolved
else:
self.create_new_client(give_focus=False)
Social-Mean marked this conversation as resolved.
Show resolved Hide resolved

# ---- Private methods
# -------------------------------------------------------------------------
Expand Down