Delay a computation in another thread

Ethan Furman ethan at stoneleaf.us
Fri Sep 8 11:36:35 EDT 2017


On 09/08/2017 07:49 AM, Steve D'Aprano wrote:
> On Sun, 3 Sep 2017 03:03 am, MRAB wrote:

>> Timer is a subclass of Thread, so you can set its .daemon attribute.
>
> Sorry for the long delay in replying to this, but if I set its daemon attribute,
> won't that mean it will live on after the interpreter shuts down?

 From the docs*:

Note Daemon threads are abruptly stopped at shutdown. Their resources (such as open files, database transactions, etc.) 
may not be released properly. If you want your threads to stop gracefully, make them non-daemonic and use a suitable 
signalling mechanism such as an Event.

--
~Ethan~

* https://docs.python.org/3/library/threading.html




More information about the Python-list mailing list