how do I catch a SystemExit exception that occurs inside a Thread object????

yinger ayinger1 at my-deja.com
Sat Nov 4 00:41:56 CET 2000


i just want to be able to detect when a Thread object terminates with a
sys.exit()

like this:


def printer(m):
	# run the some imported module here
	if m == '2':
		sys.exit(1)
	else:
		sleep(1)
		print m


for m in ('1', '2', '3', '4'):
	try:
		lt = Thread(target=printer, name=m, args=(m,))
		lt.start()
	except SystemExit:
		print 'ok, caught inner-sys exit\
                -- so terminate whole program'
		sys.exit(1)





WHY CAN'T I DO THIS!!?!?!?!?!??!



please respond to andrew at mail.idrive.com


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list