Adam Matan
Adam Matan

Reputation: 136161

uwsgi: Can't stop a Flask app

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

Answers (1)

Adam Matan
Adam Matan

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

Related Questions