Repository: spyder-ide/spyder

Issue:
jupyter_client 7.3.0 error in `__del__`
When closing spyder, issue reporter briefly opens and closes.

I've tried this on 2 different machines on fresh conda environments.
[env.txt](https://github.com/spyder-ide/spyder/files/8572651/env.txt)




Discussion:
Hi @eddaz7 thank you for the feedback. Could you try to run spyder in debug mode and post the generated log here? For that run from an Anaconda prompt spyder with the `debug-info` flag, so something like `spyder --debug-info verbose`

Let us know
yes, thanks.

2022-04-27 20:13:43,354 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin editor
2022-04-27 20:13:43,361 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin help
2022-04-27 20:13:43,362 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,363 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin internal_console
2022-04-27 20:13:43,365 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,367 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin onlinehelp
2022-04-27 20:13:43,369 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,370 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin toolbar
2022-04-27 20:13:43,371 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin shortcuts
2022-04-27 20:13:43,375 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin appearance
2022-04-27 20:13:43,375 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin application
2022-04-27 20:13:43,375 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin run
2022-04-27 20:13:43,375 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin completions
2022-04-27 20:13:43,376 [DEBUG] [spyder.plugins.completion.providers.fallback.actor] -> Fallback plugin stopping...
2022-04-27 20:13:43,376 [INFO] [spyder.plugins.completion.providers.languageserver.provider] -> Shutting down LSP manager...
2022-04-27 20:13:43,378 [INFO] [spyder.plugins.completion.providers.languageserver.provider] -> Stopping LSP client for python...
2022-04-27 20:13:43,378 [INFO] [spyder.plugins.completion.providers.languageserver.client] -> Stopping python client...
2022-04-27 20:13:43,413 [DEBUG] [spyder.plugins.editor.widgets.codeeditor] -> Stopping completion services for C:\Users\edudv\.spyder-py3\temp.py
2022-04-27 20:13:43,414 [DEBUG] [spyder.plugins.completion.providers.snippets.actor] -> Snippets plugin stopping...
2022-04-27 20:13:43,415 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin find_in_files
2022-04-27 20:13:43,417 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,424 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin variable_explorer
2022-04-27 20:13:43,426 [DEBUG] [spyder.config.manager] -> Sending notification to observers of __section in configuration section variable_explorer
2022-04-27 20:13:43,428 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,429 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin statusbar
2022-04-27 20:13:43,429 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin historylog
2022-04-27 20:13:43,432 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,432 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin project_explorer
2022-04-27 20:13:43,434 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,436 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin preferences
2022-04-27 20:13:43,436 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin main_interpreter
2022-04-27 20:13:43,437 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin tours
2022-04-27 20:13:43,437 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin outline_explorer
2022-04-27 20:13:43,439 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,439 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin plots
2022-04-27 20:13:43,441 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,441 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin pylint
2022-04-27 20:13:43,443 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,444 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin breakpoints
2022-04-27 20:13:43,446 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,446 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin workingdir
2022-04-27 20:13:43,447 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin mainmenu
2022-04-27 20:13:43,447 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin profiler
2022-04-27 20:13:43,449 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,453 [DEBUG] [asyncio] -> Using proactor: IocpProactor
2022-04-27 20:13:43,671 [DEBUG] [traitlets] -> connecting shell channel to tcp://127.0.0.1:52157
2022-04-27 20:13:43,671 [DEBUG] [traitlets] -> Connecting to: tcp://127.0.0.1:52157
Exception ignored in: <function KernelClient.__del__ at 0x000001BEFFF3A0E0>
Traceback (most recent call last):
  File "C:\Users\edudv\miniconda3\envs\ml\lib\site-packages\jupyter_client\client.py", line 122, in __del__
    if self.channels_running:
AttributeError: 'QtKernelClient' object has no attribute 'channels_running'
2022-04-27 20:13:43,678 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin ipython_console
2022-04-27 20:13:43,680 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,681 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin explorer
2022-04-27 20:13:43,683 [DEBUG] [spyder.api.widgets.main_widget] -> Docking plugin back to the main window
2022-04-27 20:13:43,690 [DEBUG] [spyder.api.plugin_registration.registry] -> Deleting plugin layout
2022-04-27 20:13:43,858 [DEBUG] [spyder.plugins.editor.widgets.editor] -> method 'editorstack_closed':
2022-04-27 20:13:43,858 [DEBUG] [spyder.plugins.editor.widgets.editor] ->     self  : <spyder.plugins.editor.widgets.editor.EditorSplitter object at 0x000001BE8597B130>
Thanks for the log @eddaz7 ! Seems like an error is being raised from `jupyter_client`:

```
Exception ignored in: <function KernelClient.del at 0x000001BEFFF3A0E0>
Traceback (most recent call last):
File "C:\Users\edudv\miniconda3\envs\ml\lib\site-packages\jupyter_client\client.py", line 122, in del
if self.channels_running:
AttributeError: 'QtKernelClient' object has no attribute 'channels_running'
```

For the moment as a workaround, could you downgrade to `jupyter_client <=7.2.0` and check if you see the Spyder error dialog? Let us know

Also pinging @ccordoba12 just in case.
thank you, for your response.
When i downgrade to **jupyter_client <=7.2.0** i don't get any errors.
However, when using **jupyter_client <=7.2.2** i did get some **asyncio** and **zmq* errors. I don't know if you are aware of this. If you want i can create other issue with logs.
About the zmq error that was reported at https://github.com/spyder-ide/spyder/issues/17615 so no need for a new issue but thank you for letting us know :+1:
I submitted https://github.com/jupyter/jupyter_client/pull/785 to fix this. If it's not accepted, we'll have to implement the same patch on our side.
@dalthviz, my PR was accepted and included in jupyter-client 7.3.1. I'll bump our requirement on that package in Spyder-kernels so that our users don't encounter this bug.

I'll do that in a couple of days because I need to wait for the package to be available in conda-forge.
nice 👍
Just in case @ccordoba12 jupyter_client 7.3.1 is already available in conda-forge: https://anaconda.org/conda-forge/jupyter_client
Great! Thanks for letting me know about it. I submitted PR https://github.com/spyder-ide/spyder-kernels/pull/382 and now I'll update our subrepo here to close this issue.

Resolving patch:
diff --git a/external-deps/spyder-kernels/setup.py b/external-deps/spyder-kernels/setup.py
--- a/external-deps/spyder-kernels/setup.py
+++ b/external-deps/spyder-kernels/setup.py
@@ -44,7 +44,7 @@ def get_version(module='spyder_kernels'):
     'ipython<6; python_version<"3"',
     'ipython>=7.31.1,<8; python_version>="3"',
     'jupyter-client>=5.3.4,<6; python_version<"3"',
-    'jupyter-client>=7.1.0; python_version>="3"',
+    'jupyter-client>=7.3.1; python_version>="3"',
     'pyzmq>=17,<20; python_version<"3"',
     'pyzmq>=22.1.0; python_version>="3"',
     'wurlitzer>=1.0.3;platform_system!="Windows"',


Test patch: