Reputation: 370
I built a web-scraper application with Python. It consists of three main parts:
The problem I have is that when the user hits X to exit the program instead of quitting through the interface, it seems like root.destroy() never gets called and the application runs forever, even though the window does disappear. This ends up consuming vast amounts of system resources.
I have tried setting all threads to Daemon without much success. Is there any other reason the program would keep eating up CPU after exit?
Upvotes: 2
Views: 488
Reputation: 7357
You don't want to set all threads to daemon
. You want to set the client thread and the back-end thread to daemon. That way, when the GUI thread dies, the threads with daemon
set to True
end as well.
From the documentation:
A thread can be flagged as a “daemon thread”. The significance of this flag is that the entire Python program exits when only daemon threads are left.
Upvotes: 2