This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pythonw crash while attempting to start() a thread object
Type: crash Stage: resolved
Components: IDLE Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, dontbugme, ezio.melotti
Priority: normal Keywords:

Created on 2010-01-12 04:22 by dontbugme, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg97622 - (view) Author: (dontbugme) Date: 2010-01-12 04:22
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()
msg97623 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-01-12 04:37
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!
>>>
msg97628 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-01-12 10:41
pythonw.exe has an invalid stdout.
Does the problem reproduce when you call print function directly, without a thread?
msg97634 - (view) Author: (dontbugme) Date: 2010-01-12 16:38
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()
msg97986 - (view) Author: (dontbugme) Date: 2010-01-17 23:31
After asking at the IRC channel, posborne resolved the error:

<posborne> 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()
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51929
2010-01-18 03:40:14brian.curtinsetresolution: not a bug
stage: resolved
2010-01-17 23:31:54dontbugmesetstatus: open -> closed

messages: + msg97986
2010-01-12 16:38:59dontbugmesetmessages: + msg97634
2010-01-12 10:41:37amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg97628
2010-01-12 04:37:30ezio.melottisetpriority: normal
nosy: + ezio.melotti
messages: + msg97623

2010-01-12 04:22:20dontbugmecreate