Commit 74e51db4 authored by Denis Bilenko's avatar Denis Bilenko

add gevent.wsgi.WSGIServer that is compatible with gevent.wsgi2.WSGIServer

parent 0b0e56ec
......@@ -30,6 +30,7 @@ from urllib import unquote
from gevent import socket
import BaseHTTPServer
from gevent.pool import Pool
from gevent.greenlet import Greenlet
DEFAULT_MAX_SIMULTANEOUS_REQUESTS = 1024
......@@ -419,3 +420,26 @@ def server(sock, site, log=None, environ=None, max_size=None, max_http_version=D
if e[0] != errno.EPIPE:
traceback.print_exc()
# compatibilty with wsgi2 module, for tests
class WSGIServer(object):
def __init__(self, address, application):
self.address = address
self.application = application
@property
def server_port(self):
return self.address[1]
def start(self):
self.socket = socket.tcp_listener(self.address)
self.address = self.socket.getsockname()
self.server = Greenlet.spawn(server, self.socket, self.application)
def stop(self):
self.server.kill(KeyboardInterrupt)
self.socket.close()
self.server.join()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment