Search code examples
pythonflaskuwsgi

autoreload python without master in uwsgi + flask


I have a Flask server, and for several reasons I need to set master = false in my uwsgi configuration. But due to this, I'm not able to auto reload on file changes anymore.

This is my uwsgi ini

[uwsgi]
master = false
enable-threads = true
wsgi-file = /opt/merlin/main.py
callable = app
protocol = http
http-socket = localhost:5000
daemonize = /var/log/merlin/merlin-app.log
env = FLASK_ENV=development
py-autoreload = 1

The reason that I need to use master = false is that I'm importing pandas and google.cloud.bigquery, and this causes the errors:

uWSGI listen queue of socket "localhost:5000" (fd: 3) full !!! (2871782829/10922)

Not exactly sure about the issue. Exploring more I found that it's related to PIL probably that causes it to not run with master = true.

So, is there any way to run python auto reload in uwsgi with master = false?


Solution

  • To sum up the discussion in the comments:

    • Use master = true whenever you can. You'll need it for many of uWSGI's nicer features.
    • Using http = localhost:5000 has uWSGI spin up a separate http-parsing/routing process; http-socket = ... does a different (worse) thing and protocol = http just sets the default protocol to be http, which you don't want. This is discussed here and here.
    • Preferably don't use daemonize = at all; use your system's process manager (e.g. systemd) to manage uWSGI and where it logs to.