"Stop" doesn't kill a python process

Hello,


for a few days now I have the problem that PyCharm (Professional) can't really end a running process when I click the red stop button. It stops printing stuff, but it's missing the "Process finished with exit code 0" and the python process is still there. If I try to rerun the process, it hangs at "Restarting Console". (If I try to close that, it hangs at "Stopping - Restarting Console")

If I manually kill the python process, I get the "Process finished with exit code 0" and can rerun the process normally. But it's very cumbersome to close every process by hand. Can anybody help me with that?I run Ubuntu 20.04 and the project is on a separate mounted SSD. Oh and I don't have this problem with debugging.

5 comments
Comment actions Permalink

When you press stop button, PyCharm sends SIGTERM signal to the process, but the process can ignore it. The issue is most likely in the process. 

To test this, you can run the code from the terminal outside of IDE and try to send the process SIGINT and SIGTERM signals manually.

To send SIGINT, simply stop the process with Ctrl+C

To send SIGTERM, run the process, open another terminal, and do `kill -15 <pid>`

0
Comment actions Permalink

I'm getting a very similar error, except I have no issue with rerunning the code. After running a script (quite basic one, only 30+ lines) the python console shows like this.  I can rerun the script and everything seems fine.  Everything behaves as expected, except I get the In[3]: at the end, where as before I was getting the Process Finishes at exit code 0.

I can click the red stop button and get the exit code.  But as the original poster mentions, this is cumbersome.

0
Comment actions Permalink

Peej1226

Perhaps you didn't run your scripts in Python Console before that?
If you disable Run with Python Console for your run configuration (Run | Edit Configurations...), then PyCharm will show the exit code as soon as the script execution finishes.

0
Comment actions Permalink

After sometime looking for solutions to this, I did indeed go to the Run Configuration.  I unchecked the Run with Python Console check box and it ran as I wanted. 

What I don't understand, is why did the configuration change like that as I would not have checked that on my own. 

0
Comment actions Permalink

One suggestion I saw was to check Emulate terminal in output console.  I actually have both unchecked and am getting the behavior I want.  What is the meaning behind Emulate terminal in output console?

0

Please sign in to leave a comment.