[Python-bugs-list] [ python-Bugs-478486 ] Example program locks up IDLE

noreply@sourceforge.net noreply@sourceforge.net
Mon, 05 Nov 2001 15:21:01 -0800


Bugs item #478486, was opened at 2001-11-05 14:59
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478486&group_id=5470

Category: IDLE
>Group: None
>Status: Closed
>Resolution: Duplicate
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Tim Peters (tim_one)
Summary: Example program locks up IDLE

Initial Comment:
Python 2.2b1 (#25, Oct 19 2001, 11:44:52) [MSC 32 bit (Intel)] on win32

Windows NT 4.x

Run the example threads code from the book _Core Python Programming_ by Wesley Chu.  IDLE 
locks up and has to be killed from the Task Manager.

Call main() in the module defined here:

import threading
from time import sleep, time, ctime

loops = [4,2]

def loop(nloop, nsec):
	print 'start ', nloop, ' at: ', ctime(time())
	sleep(nsec)
	print 'loop ', nloop, ' done  at ', ctime(time())
	
def main():
		print 'starting threads'
		threads = []
		nloops = range(len(loops))
		for i in nloops:
			t = threading.Thread(target=loop,args=(i,loops[i]))
			threads.append(t)
			
		for i in nloops:
			threads[i].start()
		
		for i in nloops:
			threads[i].join()
			
		print 'all done at ', ctime(time())
		
if __name__ == '__main__':
	main()

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

>Comment By: Tim Peters (tim_one)
Date: 2001-11-05 15:21

Message:
Logged In: YES 
user_id=31435

>From PEP 42:

"IDLE has deep problems running threaded programs.  Re-
architect."

Unless you know exactly what you're doing, running a 
threaded program under IDLE is almost guaranteed to lock up 
(several GUI systems have this problem, BTW).  Until 
someone rewrites IDLE, you'll have to run thread examples 
from a command-line shell.

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

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478486&group_id=5470