[Python-bugs-list] [Bug #121963] IDLE hangs on Threads

noreply@sourceforge.net noreply@sourceforge.net
Tue, 14 Nov 2000 09:31:51 -0800


Bug #121963, was updated on 2000-Nov-08 05:52
Here is a current snapshot of the bug.

Project: Python
Category: IDLE
Status: Closed
Resolution: Wont Fix
Bug Group: None
Priority: 5
Summary: IDLE hangs on Threads

Details: everytime my python- program starts a thread under IDLE it crashes. i use Windows 2000 and Python 2.0

Follow-Ups:

Date: 2000-Nov-13 12:35
By: gvanrossum

Comment:
Please provide more detail. What code do you use to start a thread? Does that code run correctly when using the command line interpreter (python.exe)? What kind of message do you get from the crash?
-------------------------------------------------------

Date: 2000-Nov-13 15:11
By: tim_one

Comment:
Under Win98SE, I don't see a crash but a hang is very easy to provoke (the bug report is unclear about which is happening).  For example:

def f():
    for i in range(100): print "hi", i
import thread
thread.start_new_thread(f, ())

From within IDLE, this freezes solid after a "random" number of prints, and whether typed in directly or run from a file ("Run script" from IDLE Edit menu).  Have to kill the shell from the Task Manager.

A possibly different symptom can be provoked by typing

from test import test_thread

from the IDLE prompt.

I don't think this is anything new; I always figured that threads & IDLE don't mix, and never thought more about it.

-------------------------------------------------------

Date: 2000-Nov-14 09:13
By: none

Comment:
sorry that my comment was not clear enough. my prog works when it's running under the command line interpreter. there's no error message, it just hangs. 
here's my code:

from threading import *

class MyThread(Thread):
   def __init__(self, aData):
       Thread.__init__(self)
       self.mData=Data

   def run(self):
       for i in range(10):
          print self.mData


if __name__=="__main__":
   aThread=MyThread("Test")
   bThread=MyThread("another")

   aThread.start()
   bThread.start()

   aThread.join()
   bThread.join()

   

that's it. we did this at school and my system is a Dual Pentium II with 2 x 400 Mhz and 256Mb.


-------------------------------------------------------

Date: 2000-Nov-14 09:31
By: gvanrossum

Comment:
Ah.  Yes, printing from threads started under IDLE doesn't work, and in general using threads under IDLE isn't safe.   This is not platform specific!

This isn't easy to fix; the best solution will be (eventually) to run the program in a subprocess instead of as a module in the IDLE process, but thta requires significant architectural changes to IDLE.

For the short term, the solution is to run your program from the command line, or to avoid threads if you want to run nder IDLE.

Sorry.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=121963&group_id=5470