Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

High performance asynchronous Python WSGI Web Server

Project description

What’s this

This is a high performance python wsgi web server.

Thus this is yet an another asynchronous web server like gevent.

And meinheld is a WSGI compliant web server. (PEP333 and PEP3333 supported)

You can also join us in meinheld mailing list and #meinheld on freenode


meinheld requires Python 2.x >= 2.6 or Python 3.x >= 3.2 . and greenlet >= 0.4.5.

meinheld supports Linux, FreeBSD, Mac OS X.


Install from pypi:

$ pip install -U meinheld

Install from source:

$ python install

meinheld supports gunicorn.

To install gunicorn:

$ pip install -U gunicorn

Basic Usage

simple wsgi app:

from meinheld import server

def hello_world(environ, start_response):
    status = b'200 OK'
    res = b"Hello world!"
    response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(res)))]
    start_response(status, response_headers)
    return [res]

server.listen(("", 8000))

with gunicorn. user worker class “egg:meinheld#gunicorn_worker” or “meinheld.gmeinheld.MeinheldWorker”:

$ gunicorn --workers=2 --worker-class="egg:meinheld#gunicorn_worker" gunicorn_test:app


meinheld provides a simple continuation API (based on greenlet).

To enable continuations, use ContinuationMiddleware. get Continuation from wsgi environ.

Continuation objects have two very interesting methods, suspend and resume.

For example:

from meinheld import server
from meinheld import middleware

def app(environ, start_response):

    #get Continuation
    c = environ.get(middleware.CONTINUATION_KEY, None)


    if condtion:
        for c in waiters:
            # resume suspend function


server.listen(("", 8000))

For more info see


meinheld support Websockets. use WebSocketMiddleware.

For example:

from flask import Flask, render_template, request
from meinheld import server, middleware

SECRET_KEY = 'development key'

app = Flask(__name__)

participants = set()

def index():
    return render_template('websocket_chat.html')

def chat():
    print request.environ
    ws = request.environ.get('wsgi.websocket')
        while True:
            print "ws.wait()..."
            m = ws.wait()
            print "recv msg %s" % m
            if m is None:
            for p in participants:
                print "send message %s" % m
    return ""

if __name__ == "__main__":
    server.listen(("", 8000))


meinheld provides a few monkeypatches.


This patch replaces the standard socket module.

For Example:

from meinheld import patch

For more info see


For parsing HTTP requests, meinheld uses Ryan Dahl’s http-parser library.


It is built around the high performance event library picoev.



meinheld uses sendfile(2), over wgsi.file_wrapper.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for meinheld, version 0.6.1
Filename, size File type Python version Upload date Hashes
Filename, size meinheld-0.6.1-cp36-cp36m-manylinux1_x86_64.whl (218.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size meinheld-0.6.1.tar.gz (79.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page