Spyder: The stop execution button (red square) doesn't always stop execution (looped try statements)

Created on 21 Jul 2017  路  13Comments  路  Source: spyder-ide/spyder

Description of your problem

What steps will reproduce the problem?

1) run this code:

import time
for i in range(0,100):
    try:
        time.sleep(5)
        print('hey %d'%i)
    except:
        pass
  1. try stopping it with the red square stop execution button

What is the expected output? What do you see instead?
The program stops. What actually happens is that it tries to stop once, the except part of the try statement is triggered and the script continues. But now the stop execution button is greyed out and unusable

Suggested Changes
The stop execution script should loop and continuously try until some confirmation is given that the script has stopped. The red square button shouldn't become greyed out and unusable until the script has actually stopped

Versions and main components

  • Spyder Version: 3.1.4
  • Python Version: 2.7.13 64 bit
  • Qt Version: Qt 5.6.2
  • PyQt Version: PyQt5 5.6
  • Operating system: Ubuntu 16.04 LTS

Dependencies

Please go to the menu entry Help > Optional Dependencies (or
Help > Dependencies), press the button Copy to clipboard
and paste the contents below:
jedi >=0.9.0 : 0.9.0 (OK)
matplotlib >=1.0 : 2.0.2 (OK)
nbconvert >=4.0 : 5.1.1 (OK)
numpy >=1.7 : 1.12.1 (OK)
pandas >=0.13.1 : 0.20.2 (OK)
pep8 >=0.6 : 1.7.0 (OK)
psutil >=0.3 : 5.2.1 (OK)
pyflakes >=0.5.0 : 1.5.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.6.5 (OK)
qtconsole >=4.2.0: 4.3.0 (OK)
rope >=0.9.4 : 0.10.5 (OK)
sphinx >=0.6.6 : 1.6.1 (OK)
sympy >=0.7.3 : 1.0 (OK)

IPython Console Bug

All 13 comments

Thanks for reporting. We'll take a look at this after we release our 3.2 version.

This is not so surprising to me. Pressing the stop button causes a KeyboardInterrupt exception to be raised. However, your program ignores this exception.

You get the same behaviour when you run the code in the regular Python prompt. Ctrl-C does not stop execution; you need to kill the Python interpreter.

@jitseniesen is right. There's no way to get out of your loop but killing the kernel.

So there's nothing we can do about it, sorry.

So there's no way to stop the execution of a python program from Spyder?

No if you catch every possible exception, which is what's happenning here. Else you can press Ctrl+C too.

This was unlikely due to catching exceptions. This is an issue even with normal codes. Really cumbersome to restart the kernel and rerun all codes from the top when you can't stop the kernel.

Any update on this issue in Spyder 4 ?
I still have the same issue. Once i stop by code by using the stop button.
I am unable to run any other code unless i restart the kernel.

I still have the same issue too

Spyder 3.3.6 / ipython 7.8.0

Yes, I am on Spyder 4 still facing same issue.

I can confirm, I am facing similar issues unfortunately. Thank you in advance!!

It has been so long ago that this problem was reported, today the issue remains

Still the issue remains!!! any update?

Was this page helpful?
0 / 5 - 0 ratings