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: IDLE hangs on Threads
Type: enhancement Stage:
Components: IDLE Versions:
process
Status: closed Resolution: later
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, nobody, tim.peters
Priority: normal Keywords:

Created on 2000-11-08 13:52 by anonymous, last changed 2022-04-10 16:03 by admin. This issue is now closed.

Messages (6)
msg2369 - (view) Author: Nobody/Anonymous (nobody) Date: 2000-11-08 13:52
everytime my python- program starts a thread under IDLE it crashes. i use Windows 2000 and Python 2.0
msg2370 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000-11-13 20:35
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?
msg2371 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2000-11-13 23:11
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.
msg2372 - (view) Author: Nobody/Anonymous (nobody) Date: 2000-11-14 17:13
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.

msg2373 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000-11-14 17:31
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.
msg2374 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2000-11-14 20:34
Changed to Feature Request and added to PEP42.
History
Date User Action Args
2022-04-10 16:03:29adminsetgithub: 33457
2000-11-08 13:52:30anonymouscreate