Reputation: 136161
I have a Flask app running on uwsgi. I start the app in Ubuntu with:
sudo service uwsgi start
When I try to stop the uwsgi I use:
sudo service uwsgi stop
The problem is that the stop action hangs for a long time, and when it's done I still see uwsgi workers using ps -ef | grep uwsgi
.
Why doesn't the uwsgi workers exit?
Upvotes: 0
Views: 810
Reputation: 136161
The problem is that Python threads don't die when the main thread exits, unless they are daemon threads.
The solution is to daemonize any background thread:
t = Thread(target=print_queue_size, args=())
t.setDaemon(True) # Does the trick
t.start()
Upvotes: 3