470,648 Members | 1,414 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,648 developers. It's quick & easy.

Re: Non-evil multithreaded WSGI server?

En Tue, 26 Aug 2008 03:20:53 -0300, Gerhard Häring <gh@ghaering.de>
In a recent experiment I've done this:

from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from wsgiref.simple_server import make_server, demo_app
from SocketServer import ThreadingMixIn

# Let's make a WSGI server that can use multiple threads.

class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
"""Handle requests in a separate thread."""

# Evil! ;-)
from wsgiref.simple_server import WSGIServer as MyWSGIServer
MyWSGIServer.__bases__ = (ThreadedHTTPServer,)

Now I wonder if there's a less evil way that does not involve copy &
paste of the WSGIServer code (only couple of lines, but I hate
I'm not sure I understand completely the question - does the code below
work for you?

class MyWSGIServer(ThreadingMixIn, wsgiref.simple_server.WSGIServer):

def make_server(
host, port, app, server_class=MyWSGIServer,
return wsgiref.simple_server.make_server(host, port, app,
server_class, handler_class)

Gabriel Genellina

Aug 27 '08 #1
0 998

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mario | last post: by
25 posts views Thread by Yves Glodt | last post: by
32 posts views Thread by Adrian Herscu | last post: by
8 posts views Thread by Bern McCarty | last post: by
14 posts views Thread by Patrick Kowalzick | last post: by
399 posts views Thread by =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post: by
12 posts views Thread by puzzlecracker | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.