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

Kernel process lingers after closing tab when running different interpreter and Qt5 backend #17011

Closed
10 tasks done
NicoHendrickx opened this issue Dec 13, 2021 · 7 comments
Closed
10 tasks done

Comments

@NicoHendrickx
Copy link

NicoHendrickx commented Dec 13, 2021

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

When closing the console using the cross on the tab (ctrl-dot often does not work), the python process is not killed, but lingers around, until Spyder gets restarted. This issue only occurs when you use the Qt5 graphics backend and choose a different interpreter from the default Spyder one.

Both by setting the graphics interpreter to inline or installing Spyder in the same environment will alleviate the problem (but is not a solution).

This could (for instance) result into issues when hardware connections are made, as the addresses are not freed up, and reconnection is not possible until Spyder is restarted.

What steps reproduce the problem?

  1. Set Qt5 graphics backend in Spyder.
  2. Start a kernel in a non-default interpreter (different conda env).
  3. Restart kernel by clicking the cross.

What is the expected output? What do you see instead?

Expected: underlying python thread is killed.
Instead: it stays alive

A way to visualise this, would be to initiate a Tk window. You'll see it stays alive after restarting the kernel. NOTE: this is NOT a prerequisite to have the issue occur, just a way to illustrate it.

Paste Traceback/Error Below (if applicable)

None

Versions

  • Spyder version: 5.2.0 (confirmed issue is also there in 5.1.5)
    • Tried both the standalone version and the conda version. No difference.
  • Python version: 3.9.7
  • Operating System name/version: Windows 10
@steff456
Copy link
Member

Hi @NicoHendrickx,

Thanks for reporting, can you explain to me what do you mean by "restart the kernel by clicking the cross"? The cross in the tab of the console will close it, but it won't restart it.

@NicoHendrickx
Copy link
Author

NicoHendrickx commented Dec 13, 2021

Thank you for the response. Apologies for being unclear before. I meant indeed closing it by clicking the cross in the tab of the console. If it was the only console open, a new one spawns automatically, that is why I erroneously referred to it as restarting.

Still, I would expect the python thread to be killed when the console is closed (and with a thread in the spyder environment this also happens).

/e fixed a typo

@NicoHendrickx
Copy link
Author

NicoHendrickx commented Dec 13, 2021

I closed in a bit on the issue. It's the combination of the non-default interpreter and the Qt5 graphics backend! When setting the inline graphics backend, this issue does not arise. Would that give a hint as to where the issue might arise?

I updated the initial problem report.

@NicoHendrickx NicoHendrickx changed the title Process lingers after restarting kernel when running different interpreter Process lingers after restarting kernel when running different interpreter and Qt5 backend Dec 13, 2021
@steff456
Copy link
Member

@impact27, do you know why this is hapenning?

@impact27
Copy link
Contributor

That is strange, the kernel should be killed after 10 seconds if I am not mistaken. How do you start the kernel exactly?

@NicoHendrickx
Copy link
Author

NicoHendrickx commented Dec 14, 2021

@impact27 Thanks for taking a look at this.

So, what I do is the following:

  1. Create fresh environment running python 3.9.7 and spyder-kernels, let's call it test
  2. Install pyqt5 in this environment.
  3. Run Spyder (5.2.0, but tried also 5.1.5) in either a different env, or standalone
  4. Select test python as interpreter in Spyder.
  5. Set graphics backend to Qt5
  6. Just to show the issue: start a tk window (the real issue I have is with hardware connections not freeing up)
  7. Close the console by clicking the cross on the tab.
  8. A new kernel will spawn automatically.
  9. Old process will stay alive, as can be seen by the presence of the tk window.

Now, when I try this by installing Spyder in the test environment, the issue does not show up, but I would prefer to keep Spyder separated (to avoid pyqt5 version collisions).

Note, I also tried restarting using ctrl+. but this often does not work at all. Just shows Traceback (most recent call last):.

@ccordoba12
Copy link
Member

Hey @NicoHendrickx, thanks a lot for the detailed steps you posted above! With them I was able to reproduce this problem (it seems it only happens on Windows though) and find a solution for it, which will be in our next version.

@ccordoba12 ccordoba12 assigned ccordoba12 and unassigned steff456 Dec 16, 2021
@ccordoba12 ccordoba12 changed the title Process lingers after restarting kernel when running different interpreter and Qt5 backend Kernel process lingers after closing tab when running different interpreter and Qt5 backend Dec 16, 2021
@ccordoba12 ccordoba12 added this to the v5.2.2 milestone Dec 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants