Skip to content

Instantly share code, notes, and snippets.

@nipunsadvilkar
Last active April 14, 2020 14:09
Show Gist options
  • Save nipunsadvilkar/8a901ac9b5b978df684a5d9dbb950efe to your computer and use it in GitHub Desktop.
Save nipunsadvilkar/8a901ac9b5b978df684a5d9dbb950efe to your computer and use it in GitHub Desktop.
flask and gunicorn specific deployments
  1. How to pass args or kwargs to gunicorn?
# codename/app.py
def create_app():
    app = FrameworkApp()
    ...
    return app

$ gunicorn --workers=2 'codename.app:create_app()'

Positional and keyword arguments can also be passed, but it is recommended to load configuration from environment variables rather than the command line.

  1. Resolve Gunicorn timeout error -
[2020-04-14 19:27:11 +0530] [86010] [CRITICAL] WORKER TIMEOUT (pid:86032)

or

ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

default timeout is 30 seconds. Tweak it. Example:

Setting timeout to 100 seconds

gunicorn -b localhost:5000 'codename.app:make_app(model="bert")' --timeout 100 --graceful-timeout 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment