简体   繁体   中英

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 ps -ef | grep uwsgi .

Why doesn't the uwsgi workers exit?

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM