Shutting down a cross-platform multithreaded app

Laura Creighton lac at openend.se
Fri Sep 18 22:50:36 CEST 2015


In a message of Fri, 18 Sep 2015 20:09:19 +0100, "James Harris" writes:
>> Set the daemon flag on the worker threads, so when the main thread
>> exits, the workers also exit.
>
>Interesting idea, and I did not know that a *thread* could be a daemon. 
>Unfortunately, I think what you suggest would kill the threads stone 
>dead and not allow them to close connections.

Can you stick your worker threads into a Queue.  When the main thread exits
have it tell the queue to clean itself up?

see:
http://code.activestate.com/recipes/82965-threads-tkinter-and-asynchronous-io/

The main thread doesn't have to be a gui ...

(but the author of that recipe and I are now drunkly celebrating a birthday
so maybe I ought not to be posting this idea ...)

Laura



More information about the Python-list mailing list