Skip to content

Instantly share code, notes, and snippets.

@powellc
Created March 7, 2011 20:21
Show Gist options
  • Save powellc/859135 to your computer and use it in GitHub Desktop.
Save powellc/859135 to your computer and use it in GitHub Desktop.
A development script to run django with gevent instead of flup
#!/usr/bin/python
import sys
sys.path.append('<path_to_virtualenv>')
from gevent import monkey; monkey.patch_all()
from gevent.wsgi import WSGIServer
import os
import traceback
from django.core.handlers.wsgi import WSGIHandler
from django.core.management import call_command
from django.core.signals import got_request_exception
sys.path.append('..')
os.environ['DJANGO_SETTINGS_MODULE'] = '<project name>.settings'
def exception_printer(sender, **kwargs):
traceback.print_exc()
got_request_exception.connect(exception_printer)
call_command('syncdb')
print 'Serving on 8088...'
WSGIServer(('', 8088), WSGIHandler()).serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment