Skip to content

Instantly share code, notes, and snippets.

@sethrh
Created October 17, 2016 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethrh/88197de55a3c2af09e138ca1be22806f to your computer and use it in GitHub Desktop.
Save sethrh/88197de55a3c2af09e138ca1be22806f to your computer and use it in GitHub Desktop.
UWSGI + Django, reload on code change
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your-project.settings")
application = get_wsgi_application()
try:
import uwsgi
from uwsgidecorators import timer
from django.utils import autoreload
@timer(3)
def change_code_graceful_reload(sig):
if autoreload.code_changed():
uwsgi.reload()
except ImportError:
# not running under uwsgi
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment