Exceptions in threads?

Roy Smith roy at panix.com
Mon Sep 22 00:23:59 CEST 2003


What is supposed to happen when an exception is raised and not caught in 
a thread?  The Reference Manual (section 4.2) states "When an exception 
is not handled at all, the interpreter terminates execution of the 
program, or returns to its interactive main loop", but it looks like 
what really happens is the thread is terminated, not the whole program.  
If I run the following:

-------
#!/usr/bin/env python

import time
import thread

def bogus ():
    raise Exception

thread.start_new_thread (bogus, ())
while 1:
    time.sleep (1)
    print "still alive"
-------

It keeps printing "still alive".  This is Python 2.2.2 on RedHat 6.2 
Linux.




More information about the Python-list mailing list