How does tensorflow ignore undefined flags How does tensorflow ignore undefined flags flask flask

How does tensorflow ignore undefined flags


I solved my problem by defining these flags in tensorflow model: my_tf_model.py.

tf.app.flags.DEFINE_string('bind', '', 'Server address')tf.app.flags.DEFINE_integer('timeout', 30, 'Server timeout')

And then changed my gunicorn command line to use double dash style command line:

gunicorn --bind 0.0.0.0:5000 --timeout 30 wsgi:app

But I think there should be some other way rather than this hack to resolve the globally-used flags.


I solved this problem by using gunicorn default config file: gunicorn.conf.py

You can create a config file named gunicorn.conf.py:

bind = 0.0.0.0:5000timeout = 30

FYI: Settings - Gunicorn documentation

gunicorn_conf.py is the default config file name defined in function gunicorn.config.get_default_config_file, so now you can start your service by command gunicorn wsgi:app.

Now tensorflow knows nothing about gunicorn config.

Notice: this default config name is not mentioned in gunicorn documentation, it's not sure whether this config file name remains unchanged in future version.