How to stop execution in python's Idle?

  • Context: Python 
  • Thread starter Thread starter deltapapazulu
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the challenges of stopping execution in Python's IDLE, particularly when attempting to compute extremely large numbers, such as 99999**999999999. Participants explore the behavior of IDLE during long-running calculations and the effectiveness of various interruption methods.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • One participant expresses frustration with IDLE becoming unresponsive during large calculations and seeks a method to stop the execution without restarting the application.
  • Another participant suggests that the number being calculated is too large for most programming languages, including Python, and implies that such calculations should be avoided.
  • A later reply clarifies that the original poster was aware of the impracticality of the calculation and was instead curious about IDLE's response to it.
  • Some participants mention that Ctrl-C should work to interrupt execution, but note that it may not function if the program is in a long-running native routine.
  • There is a discussion about Python's handling of large integers and the time it may take to compute such values, with one participant humorously estimating that it could take centuries.
  • One participant shares their experience of monitoring CPU and RAM usage while the calculation is ongoing, noting that Ctrl-C was ineffective in this case.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the effectiveness of Ctrl-C as a method to stop execution in IDLE, with some asserting it should work while others report it does not in certain situations. The discussion remains unresolved regarding the best approach to handle unresponsive states in IDLE.

Contextual Notes

Participants mention limitations related to the size of numbers that can be computed and the behavior of Python's signal handling during long-running calculations, but do not resolve these issues.

deltapapazulu
Messages
84
Reaction score
13
I scoured internet for answer to no avail. I am new to python and was toying with large calculations, 99999**999999999 for instance, and Idle started running and became completely non responsive. Ctrl-c didn't work. The menu in shell became non-responsive. I had to x-out & restart Idle. There's got to be a way to stop a process from executing in Idle. If there is not, that's ashamed.

I repeated the 99999**999999999 numerous times to see if I couldn't figure it out, but couldn't. Each time the window hazed over and the run wheel thing kept spinning and couldn't be stopped.

This is merely a curiosity.
 
Technology news on Phys.org
The number you're trying to calculate is way too large to compute in most programming languages. I'm not an expert in Python, but I believe that a typical Python implementation stores real numbers in 64 bits, which means that the largest such number would be 263, which is roughly 1021. The number you're trying to calculate is roughly 105,000,000,000.

In a nutshell, if your computer hangs when you try to calculate 99999999999999, then don't do that.
 
Mark44 said:
The number you're trying to calculate is way too large to compute in most programming languages. I'm not an expert in Python, but I believe that a typical Python implementation stores real numbers in 64 bits, which means that the largest such number would be 263, which is roughly 1021. The number you're trying to calculate is roughly 105,000,000,000.

In a nutshell, if your computer hangs when you try to calculate 99999999999999, then don't do that.

Perhaps I should have been more clear. I am completely aware that the calculation was outside the range of computationability. That is precisely why I attempted it. I wanted to see how python Idle would respond to it, i.e. whether it would give me a particular error message. Then when it responded the way it did I became curious as to how to break out of its locked up state without closing the application. To me that is a very reasonable thing to desire to know when learning a new application.

I actually think it is kind of amusing that you thought that the intention of my thread was to find out what 99999^9999999999 was. It should have been clear in my thread title that that was not what I was inquiring into. But thanks anyway.
 
Ctrl-C should work: try with the infinite loop while True: pass.

The problem here is presumably that the program is spending its time in a long-running native routine. Python catches the signal and delays the KeyboardInterrupt until after the native routine has finished executing, which means you'll just have to wait. (or kill it more forcefully)

Incidentally, 99999**999999999 is an integer calculation. Assuming you have 4 gigabytes or so of memory available, then given enough time, python will compute it exactly. (barring implementation errors) Of course, python doesn't use efficient arithmetic, so "enough time" is probably on the order of centuries. (And I suspect I'm underestimating)
 
Hurkyl said:
Ctrl-C should work: try with the infinite loop while True: pass.

The problem here is presumably that the program is spending its time in a long-running native routine. Python catches the signal and delays the KeyboardInterrupt until after the native routine has finished executing, which means you'll just have to wait. (or kill it more forcefully)

Incidentally, 99999**999999999 is an integer calculation. Assuming you have 4 gigabytes or so of memory available, then given enough time, python will compute it exactly. (barring implementation errors) Of course, python doesn't use efficient arithmetic, so "enough time" is probably on the order of centuries. (And I suspect I'm underestimating)

ctrl-c worked for the loop.

I ran the power calculation again to check performance in task manager. CPU usage of my Intel E8400 hovers around 55% with ram usage around 1.27gb(out of 4). I was definitely trying to compute it. Right now I am just letting it continue.

Also, before that I crept the power from 99999**9 to 99999**99999. At 99999**9999 it generated about 10 pages worth of the number. The fifth 9 in the power, though, put it in that "leave me alone I'm calculating mode" again.

Ok so right now it has been calculating 99999**999999999 for about 7 minutes and I have noticed the ram usage has been creeping up. Now it is at 1.34gb. CPU still at 55%.

Now ram is at 1.36gb. 10 minutes.

Anyway thanks for response. ctrl-c still being sidelined. Oh well, just a curiousity.
 

Similar threads