PythonW.exe crash, tested under Windows 7 x86 / x64, Python v2.6.4. The crash can be reproduced by opening and running the attached code in IDLE. TY! Error Message: Microsoft Visual C++ Runtime Library Runtime Error! Program: C:\Python26\pythonw.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Code: #!/usr/bin/env python import threading class MyThread (threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print 'hello, dude!' t = MyThread() t.start()
On 2.7a2 on Windows 7 it seems to work, I opened the script with IDLE and did F5, this is the output I got: Python 2.7a2 (r27a2:77402, Jan 10 2010, 10:04:50) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> hello, dude! >>>
I did not understand the question. If you were meaning running a plain print(), then it does work: #!/usr/bin/env python print "foo" IDLE 2.6.4 ==== No Subprocess ==== >>> foo >>> Well, as you suggested the problem most probably originates from calling print from within a thread. This code works as it should: #!/usr/bin/env python import threading class MyThread (threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): f = open('I am alive', 'w') f.write('hello, dude!\n') f.close() t = MyThread() t.start()
After asking at the IRC channel, posborne resolved the error: Also, the behaviour of exiting the main thread before all threads has exited is undefined. Is the behaviour different if you add t.join() to the end of the script? Code: #!/usr/bin/env python import threading class MyThread (threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print 'hello, dude!' t = MyThread() t.start() t.join()