Interrupting an application and keeping the console alive

Hi all,

I've been looking for a "final" python editor for ages and Pycharm seems to be the closest I can get to my ideal editor. However, before buying a full license, I want to make sure I have all the functionalities I need.

One of the most important functions for me is to be able to interrupt a script and interact with its results in the console. I see that in Pycharm I can easily keep the console open after the execution of the program, but this won't work if I interrupt the script manually (ctrl+f2). I use python for scientific research and it is very common for me to run long analyses that take days or even weeks. If I get unexpected results, I need to be able to interrupt the script and investigate every part of the stack, plotting parameters and internal variables. I can do this in ipython by simply pressing crtrl+c followed by %debug, but I couldn't find something similar in Pycharm.

Is there any way to interrupt the script and keep the console active afterwards?

Cheers,

Alessandro

2 comments
Comment actions Permalink

As mentioned here: 

https://stackoverflow.com/questions/22913490/keyboard-interrupt-in-debug-mode-pycharm/39160240#answer-57109342 

 

In recent versions of PyCharm, you can enable Emulate terminal in output console in your Run Configuration - this allows Ctrl + C in the Run console to send a keyboard interrupt.

0
Comment actions Permalink

In addition to the above reply (and this may be obvious but I'll mention just in case), if you known exact point in the script where you want to interrupt the execution, you can use the debugger. When the execution is stopped at the breakpoint, you can attach a console to the debugger and start hacking.

https://www.jetbrains.com/help/pycharm/debugging-code.html

0

Please sign in to leave a comment.