Skip to content

Commit

Permalink
fix: ignore errors on closing client and kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
hlouzada authored and ccordoba12 committed Jul 16, 2024
1 parent ca78ab5 commit d5f8088
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 12 additions & 3 deletions spyder/plugins/remoteclient/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def on_first_registration(self):
def on_close(self, cancellable=True):
"""Stops remote server and close any opened connection."""
for client in self._remote_clients.values():
AsyncDispatcher(client.close, early_return=False)()
try:
AsyncDispatcher(client.close, early_return=False)()
except Exception:
pass

@on_plugin_available(plugin=Plugins.MainMenu)
def on_mainmenu_available(self):
Expand Down Expand Up @@ -313,7 +316,10 @@ async def _shutdown_kernel(self, config_id, kernel_id):
"""Shutdown a running kernel."""
if config_id in self._remote_clients:
client = self._remote_clients[config_id]
await client.terminate_kernel(kernel_id)
try:
await client.terminate_kernel(kernel_id)
except Exception:
pass

@AsyncDispatcher.dispatch(loop='asyncssh')
async def _start_new_kernel(self, config_id):
Expand All @@ -329,7 +335,10 @@ async def _restart_kernel(self, config_id, kernel_id):
"""Restart kernel."""
if config_id in self._remote_clients:
client = self._remote_clients[config_id]
return await client.restart_kernel(kernel_id)
try:
return await client.restart_kernel(kernel_id)
except Exception:
pass

@AsyncDispatcher.dispatch(loop='asyncssh')
async def _interrupt_kernel(self, config_id, kernel_id):
Expand Down
7 changes: 4 additions & 3 deletions spyder/plugins/remoteclient/widgets/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class RemoteClientContainer(PluginMainContainer):

_sig_kernel_restarted = Signal(object, bool)
_sig_kernel_restarted = Signal(object, object)
"""
This private signal is used to inform that a kernel restart took place in
the server.
Expand All @@ -37,8 +37,9 @@ class RemoteClientContainer(PluginMainContainer):
ipyclient: ClientWidget
An IPython console client widget (the first parameter in both
signatures).
response: bool
Response returned by the server.
response: bool or None
Response returned by the server. `None` can happen when the connection
to the server is lost.
"""

sig_start_server_requested = Signal(str)
Expand Down

0 comments on commit d5f8088

Please sign in to comment.