Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to stop execution in python's Idle?

  1. Jul 5, 2010 #1
    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.
     
  2. jcsd
  3. Jul 5, 2010 #2

    Mark44

    Staff: Mentor

    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.
     
  4. Jul 5, 2010 #3
    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.
     
  5. Jul 5, 2010 #4

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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)
     
  6. Jul 5, 2010 #5
    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to stop execution in python's Idle?
  1. Executables in python (Replies: 1)

Loading...