Shutting down a cross-platform multithreaded app

James Harris james.harris.1 at gmail.com
Sat Sep 19 05:56:46 EDT 2015


"Laura Creighton" <lac at openend.se> wrote in message 
news:mailman.5.1442609448.21674.python-list at python.org...
> 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 ...)

:-)

I am not sure. The polling every 100ms or similar in periodicCall() is 
something I want to avoid. I think I have a way to do this without any 
polling.

James




More information about the Python-list mailing list