question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:29 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
pracplayopencommented, May 6, 2021

also had this problem w/out catching any exceptions (spyder 4.2.1).

wanted to mention that you can do a hard stop beyond ‘red button’ like this:

  1. find ipython console window
  2. find a console tab in this window
  3. right click on console tab
  4. click ‘restart kernel’

Shortcut to this is Ctrl+.

hope that helps.

1reaction
impact27commented, Feb 2, 2021

Hi @opendatasurgeon , I think you are running into another issue then. Could you try to update spyder, and if the problem persists, oppening a new issue with a reproducible code?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to stop Running Python Code - Super User
Im Running python code which runs continuously and i dont know how to ... See The stop execution button (red square) doesn't always...
Read more >
Python While Loop Tutorial – While True Syntax Examples ...
This type of loop runs while a given condition is True and it only stops when the condition becomes False .
Read more >
Repeating functionality - Java Programming MOOC
A program that runs infinitely does not end on its own. In NetBeans, it can be shut down by clicking the red button...
Read more >
How to stop execution of infinite loop with exception handling?
You need to add a break statement somewhere to exit the loop. ... while True: try: # anything that doesn't break loop except:...
Read more >
Control Flow — The Swift Programming Language (Swift 5.7)
When used inside a loop statement, break ends the loop's execution immediately and transfers control to the code after the loop's closing brace...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found