from gevent import monkey
monkey.patch_all(httplib=True)

# Import the rest
from django.core.handlers.wsgi import WSGIHandler as DjangoWSGIApp
from django.core.management import setup_environ
from gevent.wsgi import WSGIServer
import sys
import settings

setup_environ(settings)

# Configure host and port for the WSGI server
host = getattr(settings, 'WSGI_HOST', '127.0.0.1')
port = getattr(settings, 'WSGI_PORT', 8080)

def runserver():
    # Create the server
    application = DjangoWSGIApp()
    address = host, port
    server = WSGIServer( address, application )
    # Run the server
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        server.stop()
        sys.exit(0)

if __name__ == '__main__':
    runserver()

from gevent import monkey
monkey.patch_all()

# Import the rest
from django.core.handlers.wsgi import WSGIHandler as DjangoWSGIApp
from django.core.management import setup_environ
from gevent.wsgi import WSGIServer
import sys
import settings

setup_environ(settings)

# Configure host and port for the WSGI server
host = getattr(settings, 'WSGI_HOST', '127.0.0.1')
port = getattr(settings, 'WSGI_PORT', 8080)

def runserver():
    # Create the server
    application = DjangoWSGIApp()
    address = host, port
    server = WSGIServer( address, application )
    # Run the server
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        server.stop()
        sys.exit(0)

if __name__ == '__main__':
    runserver()

Fix httplib monkey patching problem with Gevent >= 1.0
Fix httplib monkey patching problem with Gevent >= 1.0

From v1.0 on, Gevent doesn't support monkey patching of httplib anymore.
CATMAID's example script to run a Gevent WSGI server, however, was still
expecting this to be possible. This commit fixes this.

Thanks to Mikhail Kandel for reporting.

  from gevent import monkey
- monkey.patch_all(httplib=True)
+ monkey.patch_all()
  
  # Import the rest
  from django.core.handlers.wsgi import WSGIHandler as DjangoWSGIApp
  from django.core.management import setup_environ
  from gevent.wsgi import WSGIServer
  import sys
  import settings
  
  setup_environ(settings)
  
  # Configure host and port for the WSGI server
  host = getattr(settings, 'WSGI_HOST', '127.0.0.1')
  port = getattr(settings, 'WSGI_PORT', 8080)
  
  def runserver():
      # Create the server
      application = DjangoWSGIApp()
      address = host, port
      server = WSGIServer( address, application )
      # Run the server
      try:
          server.serve_forever()
      except KeyboardInterrupt:
          server.stop()
          sys.exit(0)
  
  if __name__ == '__main__':
      runserver()
  
Fix httplib monkey patching problem with Gevent >= 1.0
## Code Before:
from gevent import monkey
monkey.patch_all(httplib=True)

# Import the rest
from django.core.handlers.wsgi import WSGIHandler as DjangoWSGIApp
from django.core.management import setup_environ
from gevent.wsgi import WSGIServer
import sys
import settings

setup_environ(settings)

# Configure host and port for the WSGI server
host = getattr(settings, 'WSGI_HOST', '127.0.0.1')
port = getattr(settings, 'WSGI_PORT', 8080)

def runserver():
    # Create the server
    application = DjangoWSGIApp()
    address = host, port
    server = WSGIServer( address, application )
    # Run the server
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        server.stop()
        sys.exit(0)

if __name__ == '__main__':
    runserver()

## Instruction:
Fix httplib monkey patching problem with Gevent >= 1.0
## Code After:
from gevent import monkey
monkey.patch_all()

# Import the rest
from django.core.handlers.wsgi import WSGIHandler as DjangoWSGIApp
from django.core.management import setup_environ
from gevent.wsgi import WSGIServer
import sys
import settings

setup_environ(settings)

# Configure host and port for the WSGI server
host = getattr(settings, 'WSGI_HOST', '127.0.0.1')
port = getattr(settings, 'WSGI_PORT', 8080)

def runserver():
    # Create the server
    application = DjangoWSGIApp()
    address = host, port
    server = WSGIServer( address, application )
    # Run the server
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        server.stop()
        sys.exit(0)

if __name__ == '__main__':
    runserver()
