Python Infinite While Loop Crashing Mac
I have a python script with a loop such as
while True:
#do something here
Whenever i r开发者_如何学Pythonun it, it will crash the mac. The mac runs Mac OS X 10.6.5 and python 2.6.1
If you can write any infinite loop and it causes a crash, then you either have a problem with your OS or your Python (since this doesn't normally cause a crash). Try out the MacPorts Python distribution and hopefully you won't have the same problems.
Maybe your computer is overheating when you let it run on 100% CPU for too long. The solution then would be make sure the fan on your CPU works or to get a better one installed.
Since you say Python 2.6.1 with OS X 10.6, I assume you are using the Apple-supplied Python 2.6. If your machine is 64-bit capable, that Python will by default run in 64-bit mode which could have an impact on stack-related issues. You could try running in 32-bit mode and see if the same thing happens; you can do that by invoking Python this way:
$ arch -i386 /usr/bin/python2.6
You could also try installing the most recent Python 2.6 (2.6.6) using the python.org installer for OS X here. Note: that Python is 32-bit only. (By the way, Python 2.7 is now current. If you can reproduce the problem with it, you should open an issue on the Python bug tracker.)
精彩评论