Why sys.exit does not exit ?

Alex Martelli aleax at aleax.it
Thu Mar 13 19:29:06 CET 2003

Gerhard Häring wrote:

> Giorge <me at nospam.pls> wrote:
>> Hi all, here is a small code snippet that should
>> tell something about what I'm trying to do:
>> import sys, os, thread, time
>> from threading import *
>> [...]
>> The problem here is that the sys.exit call doesn't
>> terminate the program, which exits after the sleep
>> call.
>> Can you help ? thanks.
> sys.exit only exits the main thread. In order for the program to finish,
> you have to complete all other threads, too.

...or set the other threads to daemonic, so their continuing existence
does not inhibit process termination (but I'm not sure how that would
play with a thread being in a system-call, such as time.sleep).


More information about the Python-list mailing list