Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapters: safely parse DEBUG environment variable #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

adapters: safely parse DEBUG environment variable #88

wants to merge 1 commit into from

Conversation

mccutchen
Copy link

Parse the value of the DEBUG environment variable defensively, to guard against breaking processes where the inotify package is imported but the value of DEBUG is not guaranteed to be an integer (e.g. as part of gunicorn --reload).

Without this change, running

DEBUG=true gunicorn --reload app

will fail with a stack trace like so:

Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 5, in <module>
    from gunicorn.app.wsgiapp import run
  File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 9, in <module>
    from gunicorn.app.base import Application
  File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 13, in <module>
    from gunicorn.config import Config, get_default_config_file
  File "/usr/local/lib/python3.8/site-packages/gunicorn/config.py", line 22, in <module>
    from gunicorn.reloader import reloader_engines
  File "/usr/local/lib/python3.8/site-packages/gunicorn/reloader.py", line 59, in <module>
    from inotify.adapters import Inotify
  File "/usr/local/lib/python3.8/site-packages/inotify/adapters.py", line 37, in <module>
    _IS_DEBUG = bool(int(os.environ.get('DEBUG', '0')))
ValueError: invalid literal for int() with base 10: 'true'

Parse the value of the DEBUG environment variable defensively, to guard against
breaking processes where the inotify package is imported but the value of DEBUG
is not guaranteed to be an integer (e.g. as part of `gunicorn --reload`).
Copy link

@CBinyenya CBinyenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants