Giter VIP home page Giter VIP logo

meinheld's Introduction

What's this

This is a high performance python wsgi web server.

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

You can also join us in meinheld mailing list.

Requirements

Meinheld requires Python 2.x >= 2.6 or Python 3.x >= 3.5 . and greenlet >= 0.4.5.

Meinheld supports Linux, FreeBSD, and macOS.

Installation

Install from pypi:

$ pip install -U meinheld

Install from source:

$ python setup.py install

Meinheld also supports working as a gunicorn worker.

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(("0.0.0.0", 8000))
server.run(hello_world)

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

Continuation

NOTE: This feature is deprecated and will be removed in 2.0

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:
        waiters.append(c)
        #suspend
        c.suspend()
    else:
        for c in waiters:
            # resume suspend function
            c.resume()

    ...


server.listen(("0.0.0.0", 8000))
server.run(middleware.ContinuationMiddleware(hello_world))

For more info see http://github.com/mopemope/meinheld/tree/master/example/chat/

Websocket

NOTE: This feature is deprecated and will be removed in 2.0

Meinheld support Websockets. use WebSocketMiddleware.

For example:

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

SECRET_KEY = 'development key'
DEBUG=True

app = Flask(__name__)
app.config.from_object(__name__)


participants = set()


@app.route('/')
def index():
    return render_template('websocket_chat.html')

@app.route('/chat')
def chat():
    print request.environ
    ws = request.environ.get('wsgi.websocket')
    participants.add(ws)
    try:
        while True:
            print "ws.wait()..."
            m = ws.wait()
            print "recv msg %s" % m
            if m is None:
                break
            for p in participants:
                print "send message %s" % m
                p.send(m)
    finally:
        participants.remove(ws)
    return ""


if __name__ == "__main__":
    server.listen(("0.0.0.0", 8000))
    server.run(middleware.WebSocketMiddleware(app))

Patching

NOTE: This feature is deprecated and will be removed in 2.0

Meinheld provides a few monkeypatches.

Socket

This patch replaces the standard socket module.

For Example:

from meinheld import patch
patch.patch_all()

For more info see http://github.com/mopemope/meinheld/tree/master/example/patch/

Performance

For parsing HTTP requests, Meinheld uses Ryan Dahl's http-parser library.

(see https://github.com/joyent/http-parser)

It is built around the high performance event library picoev.

(see http://developer.cybozu.co.jp/kazuho/2009/08/picoev-a-tiny-e.html)

Sendfile

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

meinheld's People

Contributors

0-wiz-0 avatar awestendorf avatar bulletmark avatar donspaulding avatar hhatto avatar ipetrik avatar javabrett avatar makt avatar methane avatar mopemope avatar ricardo-kagawa avatar skrytebane avatar sobolevn avatar yamaneko1212 avatar yosisa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meinheld's Issues

Reduce writev

Currently, writev is heavily used for writing header.
There are three iovec for one header field. (e.g. Content-Type, :, text/plain, \r\n.)
But writev is slow for writing many small chunk of memories.

So we should use memcpy to build header.

multiple simultaneous requests

He was performing a test with meinheld, I was trying to test whether it is possible to address several requests at once. I see that the server listens only 1 to 1.

Is there any way to change this? I would like the requests received have the same context and not try a fork process.

I tried to use gunicorn + meinheld, now if I can handle several at a time, but do not share memory for me is a problem. I tried to put --threads 10, but to indicate that parameter only serves 1 to 1

from bottle import run, get
import time


@get("/test_yield")
def test_yield():
    print("init test_yield")
    for x in range(10):
        time.sleep(1)
        yield(str(x))
    print("end test_yield")

if __name__ == "__main__":
    run(server="meinheld", port="9876", host="0.0.0.0")
init test_yield
end test_yield
"127.0.0.1 - - [30/Jun/2016:11:32:59 +0000] "GET /test_yield HTTP/1.1" 200 10 "-" "Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/3.0.5"
init test_yield
end test_yield
"127.0.0.1 - - [30/Jun/2016:11:33:09 +0000] "GET /test_yield HTTP/1.1" 200 10 "-" "Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/3.0.5"

ImportError: <module 'meinheld.gmeinheld' from '/usr/local/lib/python3.3/site-packages/meinheld/gmeinheld.py'> has no 'MeinheldWorker' attribute ]

gunicorn --pid realURL.pid --bind 127.0.0.1:6889 --workers=2 --worker-class="egg:meinheld#gunicorn_worker" main:app

Error: class uri 'egg:meinheld#gunicorn_worker' invalid or not found:

[Traceback (most recent call last):
File "/usr/local/lib/python3.3/site-packages/pkg_resources.py", line 2032, in load
entry = getattr(entry,attr)
AttributeError: 'module' object has no attribute 'MeinheldWorker'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.3/site-packages/gunicorn/util.py", line 112, in load_class
return pkg_resources.load_entry_point(dist, section, name)
File "/usr/local/lib/python3.3/site-packages/pkg_resources.py", line 353, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.3/site-packages/pkg_resources.py", line 2302, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.3/site-packages/pkg_resources.py", line 2034, in load
raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError: <module 'meinheld.gmeinheld' from '/usr/local/lib/python3.3/site-packages/meinheld/gmeinheld.py'> has no 'MeinheldWorker' attribute
]

and i modify the gemeinheld.py
row 12:
if not is_py3():
->
if is_py3():

then it run:
gunicorn --pid realURL.pid --bind 127.0.0.1:6889 --workers=2 --worker-class="egg:meinheld#gunicorn_worker" main:app
2014-01-24 14:08:40 [2500] [INFO] Starting gunicorn 18.0
2014-01-24 14:08:40 [2500] [INFO] Listening at: http://127.0.0.1:6889 (2500)
2014-01-24 14:08:40 [2500] [INFO] Using worker: egg:meinheld#gunicorn_worker
2014-01-24 14:08:40 [2503] [INFO] Booting worker with pid: 2503
2014-01-24 14:08:40 [2504] [INFO] Booting worker with pid: 2504

can you see the problem. thanks.

debian 8 + python3.3.3 + gunicorn18 + meinheld

thanks

SSL Support

Will Meinheld support SSL?
Is it possible that we contribute SSL support for Meinheld?

Process seg faults on a get request

$ python hello_world.py
client size 100
request size 564
header size 8
header bucket 28
accept fd 5
use pooled client 0x9515850


GET / HTTP/1.0
Host: 127.0.0.1:8000
User-Agent: ApacheBench/2.3
Accept: /

6๏ฟฝk0วฟ
message_begin_cb
use pooled req 0x95ccb40
use pooled buf 0x96cbd90
use pooled buf 0x96cbd78
use pooled header 0x960bd98
use pooled buf 0x96cbd60
use pooled buf 0x96cbd48
use pooled header 0x960bd88
use pooled buf 0x96cbd30
use pooled buf 0x96cbd18
use pooled header 0x960bd78
use pooled buf 0x96cbd00
use pooled buf 0x96cbce8
back to buffer pool 0x96cbd78
back to buffer pool 0x96cbd90
back to buffer pool 0x96cbd60
back to buffer pool 0x96cbd48
back to header pool 0x960bd98
back to buffer pool 0x96cbd30
back to buffer pool 0x96cbd18
back to header pool 0x960bd88
back to buffer pool 0x96cbd00
back to buffer pool 0x96cbce8
back to header pool 0x960bd78
use pooled ClientObject 0xb70a86c0
ClientObject_New pyclient:0xb70a86c0 client:0x9515850 fd:5
headers_complete_cb
message_complete_cb
read request fd 5 readed 82 nread 82
parse ok, fd 5 82 nread
back to request pool 0x95ccb40
use pooled buf 0x96cbce8
use pooled StringIOObject 0xb70ab150
start client 0x9515850
start environ 0xb70a02d4
[1] 18238 segmentation fault python hello_world.py

Encode error with Unicode urls

I am using Meinheld as Gunicorn worker for Django project. Setup is working on Python 3.5 under Ubuntu 16.04. Nginx is running as reverse proxy for Gunicorn.

Django tries to encode urls from utf-8 to latin-1 (ISO_8859_1) and fails.

I have tried to reproduce this error with Django's devserver and with Gunicorn default worker. Both doesn't have described problem.

Package versions:

meinheld (0.6.0)
gunicorn (19.6.0)
Django (1.10.2)

did not support python 3.6

t.py

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(("0.0.0.0", 8000))
server.run(hello_world)

python t3.py(with pyenv and python 3.6.0)

python t.py
Traceback (most recent call last):
File "t.py", line 1, in
from meinheld import server
File "/tmp/jj/lib/python3.6/site-packages/meinheld/init.py", line 1, in
from meinheld.server import *
ImportError: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory

Segmentation fault in kill_server

I get an segmentation fault when the server is supposed to shut down.
Just running:

python example/hello_world.py

as soon as I hit CTRL-C it will segfault.

More info:

Version:         2.7.3 (2.7.3)
Code Type:       X86-64 (Native)
OS Version:      Mac OS X 10.8.2 (12C3006)

Crashed Thread:  0  Dispatch queue: com.apple.main-thread
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000048

VM Regions Near 0x48:
--> 
    __TEXT                 0000000107545000-0000000107546000 [    4K] r-x/rwx SM=COW  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   org.python.python               0x00000001075f61de PyErr_Occurred + 14
1   server.so                       0x00000001078f289a kill_server + 58 (server.c:436)
2   server.so                       0x00000001078f261b sigint_cb + 11 (server.c:1577)
3   libsystem_c.dylib               0x00007fff8657d8ea _sigtramp + 26
4   libsystem_kernel.dylib          0x00007fff84205d16 kevent + 10
5   server.so                       0x00000001078f4bc6 picoev_poll_once_internal + 86 (picoev_kqueue.c:182)
6   server.so                       0x00000001078f1d9d meinheld_run_loop + 1517 (picoev.h:388)
7   org.python.python               0x00000001075e5797 PyEval_EvalFrameEx + 9911
8   org.python.python               0x00000001075e3096 PyEval_EvalCodeEx + 1990
9   org.python.python               0x00000001075e28c6 PyEval_EvalCode + 54
10  org.python.python               0x0000000107609aee PyRun_FileExFlags + 174
11  org.python.python               0x0000000107609659 PyRun_SimpleFileExFlags + 777
12  org.python.python               0x000000010761d378 Py_Main + 2952
13  libdyld.dylib                   0x00007fff888bc7e1 start + 1

Tell me if I can help you to solve this issue.

Values associated with duplicate header keys no longer included in response

After httpbin switched to meinheld this issue came up in an automated test being run against httpbin. It seems meinheld is ignoring duplicate header keys.

Expected:
"X-Blah": "Foo,Bar"
Actual:
"X-Blah": "Bar"

Request:

GET /get HTTP/1.1
X-Blah: Foo
X-Blah: Bar
Accept-Encoding: gzip
Host: httpbin.org

Response:

HTTP/1.1 200 OK
Connection: keep-alive
Server: meinheld/0.6.1
Date: Fri, 12 May 2017 11:31:38 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000745058059692
Content-Length: 212
Via: 1.1 vegur

{
  "args": {}, 
  "headers": {
    "Accept-Encoding": "gzip", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "X-Blah": "Bar"
  }, 
  "origin": "redacted", 
  "url": "http://httpbin.org/get"
}

did meinehld close alchemy scoped session before the end of template render

I've recently test meinheld with a complete wsgi application build with pyramid/mako/sqlalchemy stack and encountered some strange exceptions.

DetachedInstanceError
Parent instance <MyUser at 0xf19f250> is not bound to a Session; lazy load operation of attribute 'addresses' cannot proceed.

All these exceptions have the same concern : the fact that objects used inside
mako template were not boud to a session so lazy load operation of an attribute cannot proceed.

We usually use pserve/cherrypy and have never had those exceptions. I mean, it's
hard to know which part of the stack don't respect thread event end and close scoped session to early. I just start with meinheld :)

I would try to build a small sample app to reproduce the problem. thx

Expected in : flat namespace (issues on running Meinheld on Mac OS X mountain lion)

I installed meinheld from easy_install and trying to run the example I cannot load the lib. I'm using the stock python v 2.7.2

I have this in my .profile to be able to run the mysql lib for my django :

export VERSIONER_PYTHON_PREFER_32_BIT=yes
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib

And here is the error I'm getting :

>>> from meinheld import server
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/meinheld-0.4.15-py2.7-macosx-10.8-intel.egg/meinheld/__init__.py", line 1, in <module>
    from meinheld.server import *
ImportError: dlopen(/Library/Python/2.7/site-packages/meinheld-0.4.15-py2.7-macosx-10.8-intel.egg/meinheld/server.so, 2): Symbol not found: _StringIOObject_dealloc
  Referenced from: /Library/Python/2.7/site-packages/meinheld-0.4.15-py2.7-macosx-10.8-intel.egg/meinheld/server.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/meinheld-0.4.15-py2.7-macosx-10.8-intel.egg/meinheld/server.so

any idea of how to solve this?

gunicorn segfault on POST request with field of same name like in query string

I have a login view that should redirect to the url which is in the forward_to url parameter after successful login

https:///backend/login?forward_to=
the form has also a hidden forward_to field

when the POST field and the GET field of the same name is set
I get a segfault of gunicorn:
Mar 27 12:23:41 --- kernel: [ 807.030940] gunicorn[2682]: segfault at 8 ip 000000000046deb8 sp 00007fff540fb030 error 4 in python[400000+234000]

Crash in server.c

Not sure whether/how meinheld is related but I'll post here to get a comment. I have been using meinheld happily for years for my home alarm system running on a raspberry pi. Some time ago I ported to Arch on a RPi2. Today I saw a core dump which I believe may be related to the relatively recent upgrade on Arch from python 3.4 to python 3.5:

pi@pi3:~ coredumpctl --no-pager info 
           PID: 220 (python)
           UID: 1000 (pi)
           GID: 1000 (pi)
        Signal: 11 (SEGV)
     Timestamp: Wed 2015-12-02 05:10:32 AEST (6h ago)
  Command Line: env/bin/python pialarm
    Executable: /usr/bin/python3.5
 Control Group: /user.slice/user-1000.slice/[email protected]/pialarm.service
          Unit: [email protected]
         Slice: user-1000.slice
     Owner UID: 1000 (pi)
       Boot ID: bcca24ad226540f8a6a397a9dc33ff85
    Machine ID: 663f6cee40174da8ab551172a29af2b2
      Hostname: pi3
      Coredump: /var/lib/systemd/coredump/core.python.1000.bcca24ad226540f8a6a397a9dc33ff85.220.1448997032000000.lz4
       Message: Process 220 (python) of user 1000 dumped core.

                Stack trace of thread 220:
                #0  0x0000000075428ec8 parse_http_request (server.cpython-35m-arm-linux-gnueabihf.so)
                #1  0x0000000075429094 read_callback (server.cpython-35m-arm-linux-gnueabihf.so)
                #2  0x00000000754347c8 picoev_poll_once_internal (server.cpython-35m-arm-linux-gnueabihf.so)
                #3  0x000000007542b4e4 picoev_loop_once (server.cpython-35m-arm-linux-gnueabihf.so)
                #4  0x0000000076d70068 PyCFunction_Call (libpython3.5m.so.1.0)

Presumably this may be due to greenlet? I see that meinheld requires specific greenlet version 0.4.5 although 0.4.9 is on PyPI. Any reason it can't use the most update to date package?

Invalid encoded url problem

$ python hello_world.py

I tried this.

curl -L 0.0.0.0:8000/?q=%XY

I expected server returns 400 Bad Request, but 'hello world!' is returned.

Is it bug?

Question about thread and gunicorn

Well, meinheld is fast, so I chose it. Now, I fork a new thread in my app to do some corn tasks, if I use gunicorn as frontend, is it made any problem? Or, is any native api provide by meinheld to help me do some corn tasks?

Frequent RequestTimeout errors

Looking at tcpdump:

23:35:22.157828 IP localhost.58568 > localhost.irdmi: Flags [P.], seq 3091023342:3091023579, ack 2928175264, win 9186, options [nop,nop,TS val 741129904 ecr 741129904], length 237
E..!_.@.@..............@.=E...h...#........
,,..,,..POST /receipt HTTP/1.1
Host: localhost:8000
Accept-Encoding: gzip, deflate, compress
Content-Length: 3
Content-Type: application/x-www-form-urlencoded
User-Agent: python-requests/2.1.0 CPython/3.3.3 Darwin/13.1.0
Accept: */*

sdf
23:35:22.158618 IP localhost.irdmi > localhost.58568: Flags [P.], seq 1:202, ack 237, win 9171, options [nop,nop,TS val 741129905 ecr 741129904], length 201
E....&@.@[email protected]..=F...#........
,,..,,..HTTP/1.1 200 OK
Server: meinheld/0.5.6
Date: Tue, 27 May 2014 21:35:22 GMT
Content-Type: text/plain
Content-Length: 7
Strict-Transport-Security: max-age=31536000
Connection: Keep-Alive

INVALID
23:35:24.159993 IP localhost.irdmi > localhost.58568: Flags [P.], seq 202:375, ack 237, win 9171, options [nop,nop,TS val 741131902 ecr 741129905], length 173
E....K@.@[email protected].=F...#........
,,.~,,..HTTP/1.0 408 Request Timeout
Content-Type: text/html
Server: meinheld/0.5.6

<html><head><title>Request Timeout</title></head><body><p>Request Timeout.</p></body></html>

My interpretation/guess is that a second, unsolicited response comes in over the Keep-Alive connection after the proper one, and both Firefox and Chrome decide to display the second response when I refresh.

Meinheld + NGINX proxy causes content truncation

Hey guys,

Had an ELB -> NGINX -> Gunicorn + Meinheld and kept getting a net::ERR_CONTENT_LENGTH_MISMATCH when I disabled cache via chrome console. Once I removed Meinheld everything worked. Not sure what the issue was, but here's the NGINX config and the run command.

Run command:

gunicorn -w $(($(nproc) * 2 + 1)) -t 60 --worker-class="egg:meinheld#gunicorn_worker" --bind 0.0.0.0:5000 app:app

Proxy config:

    map $http_upgrade $connection_upgrade {
        default        "upgrade";
        ""            "";
    }
    
    server {
        listen 80;

    	gzip on;
	    gzip_comp_level 4;
	    gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
            set $year $1;
            set $month $2;
            set $day $3;
            set $hour $4;
        }
        access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;

        access_log    /var/log/nginx/access.log;
    
        location / {
            proxy_pass            http://docker;
            proxy_http_version    1.1;
    
            proxy_set_header    Connection            $connection_upgrade;
            proxy_set_header    Upgrade                $http_upgrade;
            proxy_set_header    Host                $host;
            proxy_set_header    X-Real-IP            $remote_addr;
            proxy_set_header    X-Forwarded-For        $proxy_add_x_forwarded_for;
        }
    }

and NGINX.conf

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log    /var/log/nginx/access.log;

    log_format  healthd '$msec"$uri"$status"$request_time"$upstream_response_time"$http_x_forwarded_for';

    include       /etc/nginx/conf.d/*.conf;
    include       /etc/nginx/sites-enabled/*;
}

SSLError

Hi,

I've been using meinheld as a backend with chaussette to run my webapp. I've run into a problem that while trying to make a post request with the requests library I get the following exception:

SSLError: [Errno 2] _ssl.c:504: The operation did not complete (read)

But when I change the backend to waitress (for example) the problem is gone. So I thought it had something to do with meinheld.

Thanks

HTTPConnection from httplib gives segfault

A simple example:

from meinheld.patch import patch_socket
patch_socket()
from httplib import HTTPConnection

conn = HTTPConnection('www.google.com', 80)                                                                                                                               
conn.connect()

Frequent crashes

We are currently testing a BottlePY based with meinheld and we see frequently these crashes....is this related to Python or meinheld in particular?

Linux unknown-device 4.7.0-1-amd64 #1 SMP Debian 4.7.2-1 (2016-08-28) x86_64 GNU/Linux
2017-08-31 17:40:55,434] WARNING JWK verification disabled
[2017-08-31 17:40:55,435] INFO pimservice version 0.2.0.dev0
[2017-08-31 17:40:55,435] INFO Importing data from /home/nils/src/festool/coa-pim-service/SCPortal_de-DE_20170418.xml.zip
[2017-08-31 17:40:55,435] INFO Locales in ZIP file: de-DE
Loading SCPortal_de-DE_20170418.xml (1/1) โ€ฆ done.
Bottle v0.12.12 server starting up (using MeinheldServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.

"0.0.0.0 - - [31/Aug/2017:17:41:27 +0000] "GET /Search/de-DE HTTP/1.1" 200 105256 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
*** stack smashing detected ***: /home/nils/src/festool/coa-pim-service/bin/python terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bcb)[0x7fdcddbabbcb]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7fdcddc34227]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x0)[0x7fdcddc341f0]
/home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/meinheld-0.6.1-py3.6-linux-x86_64.egg/meinheld/server.cpython-36m-x86_64-linux-gnu.so(+0xebdf)[0x7fdcd49c8bdf]
/home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/meinheld-0.6.1-py3.6-linux-x86_64.egg/meinheld/server.cpython-36m-x86_64-linux-gnu.so(picoev_poll_once_internal+0x95)[0x7fdcd49ce1c5]
/home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/meinheld-0.6.1-py3.6-linux-x86_64.egg/meinheld/server.cpython-36m-x86_64-linux-gnu.so(+0xfc87)[0x7fdcd49c9c87]
/home/nils/src/festool/coa-pim-service/bin/python(_PyCFunction_FastCallKeywords+0x1a7)[0x4bdcb7]
/home/nils/src/festool/coa-pim-service/bin/python[0x54d47e]
/home/nils/src/festool/coa-pim-service/bin/python(_PyEval_EvalFrameDefault+0x2e63)[0x5512d3]
/home/nils/src/festool/coa-pim-service/bin/python[0x54c681]
/home/nils/src/festool/coa-pim-service/bin/python[0x54d5f5]
/home/nils/src/festool/coa-pim-service/bin/python(_PyEval_EvalFrameDefault+0x2e63)[0x5512d3]
/home/nils/src/festool/coa-pim-service/bin/python[0x54d0d5]
/home/nils/src/festool/coa-pim-service/bin/python(PyEval_EvalCodeEx+0x2f)[0x54dfaf]
/home/nils/src/festool/coa-pim-service/bin/python[0x488cf6]
/home/nils/src/festool/coa-pim-service/bin/python(PyObject_Call+0x3a)[0x4562fa]
/home/nils/src/festool/coa-pim-service/bin/python(_PyEval_EvalFrameDefault+0x32b6)[0x551726]
/home/nils/src/festool/coa-pim-service/bin/python[0x54d0d5]
/home/nils/src/festool/coa-pim-service/bin/python[0x54d394]
/home/nils/src/festool/coa-pim-service/bin/python(_PyEval_EvalFrameDefault+0x3178)[0x5515e8]
/home/nils/src/festool/coa-pim-service/bin/python[0x54c681]
/home/nils/src/festool/coa-pim-service/bin/python[0x54d5f5]
/home/nils/src/festool/coa-pim-service/bin/python(_PyEval_EvalFrameDefault+0x2e63)[0x5512d3]
/home/nils/src/festool/coa-pim-service/bin/python[0x54d0d5]
/home/nils/src/festool/coa-pim-service/bin/python(PyEval_EvalCode+0x23)[0x54df43]
/home/nils/src/festool/coa-pim-service/bin/python(PyRun_FileExFlags+0x167)[0x42ac17]
/home/nils/src/festool/coa-pim-service/bin/python(PyRun_SimpleFileExFlags+0xeb)[0x42ae4b]
/home/nils/src/festool/coa-pim-service/bin/python(Py_Main+0xd8f)[0x43f12f]
/home/nils/src/festool/coa-pim-service/bin/python(main+0x167)[0x421337]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7fdcddb5b2b1]
/home/nils/src/festool/coa-pim-service/bin/python(_start+0x2a)[0x42140a]
======= Memory map: ========
00400000-007aa000 r-xp 00000000 fe:01 18486295                           /usr/bin/python3.6
009a9000-009aa000 r--p 003a9000 fe:01 18486295                           /usr/bin/python3.6
009aa000-00a45000 rw-p 003aa000 fe:01 18486295                           /usr/bin/python3.6
00a45000-00a77000 rw-p 00000000 00:00 0 
00fa0000-15978000 rw-p 00000000 00:00 0                                  [heap]
7fdcd4533000-7fdcd4673000 rw-p 00000000 00:00 0 
7fdcd4673000-7fdcd4679000 r-xp 00000000 fe:01 14027603                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/greenlet-0.4.12-py3.6-linux-x86_64.egg/greenlet.cpython-36m-x86_64-linux-gnu.so
7fdcd4679000-7fdcd4878000 ---p 00006000 fe:01 14027603                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/greenlet-0.4.12-py3.6-linux-x86_64.egg/greenlet.cpython-36m-x86_64-linux-gnu.so
7fdcd4878000-7fdcd4879000 r--p 00005000 fe:01 14027603                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/greenlet-0.4.12-py3.6-linux-x86_64.egg/greenlet.cpython-36m-x86_64-linux-gnu.so
7fdcd4879000-7fdcd487a000 rw-p 00006000 fe:01 14027603                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/greenlet-0.4.12-py3.6-linux-x86_64.egg/greenlet.cpython-36m-x86_64-linux-gnu.so
7fdcd487a000-7fdcd49ba000 rw-p 00000000 00:00 0 
7fdcd49ba000-7fdcd49d3000 r-xp 00000000 fe:01 29107634                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/meinheld-0.6.1-py3.6-linux-x86_64.egg/meinheld/server.cpython-36m-x86_64-linux-gnu.so
7fdcd49d3000-7fdcd4bd2000 ---p 00019000 fe:01 29107634                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/meinheld-0.6.1-py3.6-linux-x86_64.egg/meinheld/server.cpython-36m-x86_64-linux-gnu.so
7fdcd4bd2000-7fdcd4bd3000 r--p 00018000 fe:01 29107634                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/meinheld-0.6.1-py3.6-linux-x86_64.egg/meinheld/server.cpython-36m-x86_64-linux-gnu.so
7fdcd4bd3000-7fdcd4bd5000 rw-p 00019000 fe:01 29107634                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/meinheld-0.6.1-py3.6-linux-x86_64.egg/meinheld/server.cpython-36m-x86_64-linux-gnu.so
7fdcd4bd5000-7fdcd5ee1000 rw-p 00000000 00:00 0 
7fdcd5ee1000-7fdcd5eeb000 r-xp 00000000 fe:01 6422899                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7fdcd5eeb000-7fdcd60eb000 ---p 0000a000 fe:01 6422899                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7fdcd60eb000-7fdcd60ec000 r--p 0000a000 fe:01 6422899                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7fdcd60ec000-7fdcd60ed000 rw-p 0000b000 fe:01 6422899                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7fdcd60ed000-7fdcd6234000 rw-p 00000000 00:00 0 
7fdcd6234000-7fdcd626c000 r-xp 00000000 fe:01 18491635                   /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7fdcd626c000-7fdcd646b000 ---p 00038000 fe:01 18491635                   /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7fdcd646b000-7fdcd646c000 r--p 00037000 fe:01 18491635                   /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7fdcd646c000-7fdcd646d000 rw-p 00038000 fe:01 18491635                   /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7fdcd646d000-7fdcd648d000 r-xp 00000000 fe:01 18757840                   /usr/lib/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so
7fdcd648d000-7fdcd668c000 ---p 00020000 fe:01 18757840                   /usr/lib/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so
7fdcd668c000-7fdcd668d000 r--p 0001f000 fe:01 18757840                   /usr/lib/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so
7fdcd668d000-7fdcd6696000 rw-p 00020000 fe:01 18757840                   /usr/lib/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so
7fdcd6696000-7fdcd66ac000 r-xp 00000000 fe:01 6422603                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fdcd66ac000-7fdcd68ab000 ---p 00016000 fe:01 6422603                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fdcd68ab000-7fdcd68ac000 r--p 00015000 fe:01 6422603                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fdcd68ac000-7fdcd68ad000 rw-p 00016000 fe:01 6422603                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fdcd68ad000-7fdcd6a1f000 r-xp 00000000 fe:01 18481948                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fdcd6a1f000-7fdcd6c1f000 ---p 00172000 fe:01 18481948                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fdcd6c1f000-7fdcd6c29000 r--p 00172000 fe:01 18481948                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fdcd6c29000-7fdcd6c2b000 rw-p 0017c000 fe:01 18481948                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fdcd6c2b000-7fdcd6c2f000 rw-p 00000000 00:00 0 
7fdcd6c2f000-7fdcd6c42000 r-xp 00000000 fe:01 6422643                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7fdcd6c42000-7fdcd6e41000 ---p 00013000 fe:01 6422643                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7fdcd6e41000-7fdcd6e42000 r--p 00012000 fe:01 6422643                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7fdcd6e42000-7fdcd6e43000 rw-p 00013000 fe:01 6422643                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7fdcd6e43000-7fdcd86bf000 r-xp 00000000 fe:01 18486226                   /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7fdcd86bf000-7fdcd88be000 ---p 0187c000 fe:01 18486226                   /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7fdcd88be000-7fdcd88bf000 r--p 0187b000 fe:01 18486226                   /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7fdcd88bf000-7fdcd88c0000 rw-p 0187c000 fe:01 18486226                   /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7fdcd88c0000-7fdcd8a54000 r-xp 00000000 fe:01 18488734                   /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7fdcd8a54000-7fdcd8c53000 ---p 00194000 fe:01 18488734                   /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7fdcd8c53000-7fdcd8c65000 r--p 00193000 fe:01 18488734                   /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7fdcd8c65000-7fdcd8c66000 rw-p 001a5000 fe:01 18488734                   /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7fdcd8c66000-7fdcd8c68000 rw-p 00000000 00:00 0 
7fdcd8c68000-7fdcd8ed3000 r-xp 00000000 fe:01 18486229                   /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7fdcd8ed3000-7fdcd90d2000 ---p 0026b000 fe:01 18486229                   /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7fdcd90d2000-7fdcd90df000 r--p 0026a000 fe:01 18486229                   /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7fdcd90df000-7fdcd90e1000 rw-p 00277000 fe:01 18486229                   /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7fdcd90e1000-7fdcd90e2000 rw-p 00000000 00:00 0 
7fdcd90e2000-7fdcd91e9000 r-xp 00000000 fe:01 6422553                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7fdcd91e9000-7fdcd93e8000 ---p 00107000 fe:01 6422553                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7fdcd93e8000-7fdcd93ea000 r--p 00106000 fe:01 6422553                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7fdcd93ea000-7fdcd93f1000 rw-p 00108000 fe:01 6422553                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7fdcd93f1000-7fdcd93f8000 r-xp 00000000 fe:01 6422916                    /lib/x86_64-linux-gnu/librt-2.24.so
7fdcd93f8000-7fdcd95f7000 ---p 00007000 fe:01 6422916                    /lib/x86_64-linux-gnu/librt-2.24.so
7fdcd95f7000-7fdcd95f8000 r--p 00006000 fe:01 6422916                    /lib/x86_64-linux-gnu/librt-2.24.so
7fdcd95f8000-7fdcd95f9000 rw-p 00007000 fe:01 6422916                    /lib/x86_64-linux-gnu/librt-2.24.so
7fdcd95f9000-7fdcd97a9000 r-xp 00000000 fe:01 18489412                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7fdcd97a9000-7fdcd99a9000 ---p 001b0000 fe:01 18489412                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7fdcd99a9000-7fdcd99b1000 r--p 001b0000 fe:01 18489412                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7fdcd99b1000-7fdcd99b3000 rw-p 001b8000 fe:01 18489412                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7fdcd99b3000-7fdcd99b4000 rw-p 00000000 00:00 0 
7fdcd99b4000-7fdcd99c8000 r-xp 00000000 fe:01 18485011                   /usr/lib/x86_64-linux-gnu/libexslt.so.0.8.17
7fdcd99c8000-7fdcd9bc8000 ---p 00014000 fe:01 18485011                   /usr/lib/x86_64-linux-gnu/libexslt.so.0.8.17
7fdcd9bc8000-7fdcd9bc9000 r--p 00014000 fe:01 18485011                   /usr/lib/x86_64-linux-gnu/libexslt.so.0.8.17
7fdcd9bc9000-7fdcd9bca000 rw-p 00015000 fe:01 18485011                   /usr/lib/x86_64-linux-gnu/libexslt.so.0.8.17
7fdcd9bca000-7fdcd9c07000 r-xp 00000000 fe:01 18485012                   /usr/lib/x86_64-linux-gnu/libxslt.so.1.1.29
7fdcd9c07000-7fdcd9e06000 ---p 0003d000 fe:01 18485012                   /usr/lib/x86_64-linux-gnu/libxslt.so.1.1.29
7fdcd9e06000-7fdcd9e08000 r--p 0003c000 fe:01 18485012                   /usr/lib/x86_64-linux-gnu/libxslt.so.1.1.29
7fdcd9e08000-7fdcd9e09000 rw-p 0003e000 fe:01 18485012                   /usr/lib/x86_64-linux-gnu/libxslt.so.1.1.29
7fdcd9e09000-7fdcd9ff0000 r-xp 00000000 fe:01 12868319                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/lxml-3.8.0-py3.6-linux-x86_64.egg/lxml/etree.cpython-36m-x86_64-linux-gnu.so
7fdcd9ff0000-7fdcda1ef000 ---p 001e7000 fe:01 12868319                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/lxml-3.8.0-py3.6-linux-x86_64.egg/lxml/etree.cpython-36m-x86_64-linux-gnu.so
7fdcda1ef000-7fdcda1f0000 r--p 001e6000 fe:01 12868319                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/lxml-3.8.0-py3.6-linux-x86_64.egg/lxml/etree.cpython-36m-x86_64-linux-gnu.so
7fdcda1f0000-7fdcda220000 rw-p 001e7000 fe:01 12868319                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/lxml-3.8.0-py3.6-linux-x86_64.egg/lxml/etree.cpython-36m-x86_64-linux-gnu.so
7fdcda220000-7fdcda227000 rw-p 00000000 00:00 0 
7fdcda227000-7fdcda229000 r-xp 00000000 fe:01 13635416                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_padding.abi3.so
7fdcda229000-7fdcda428000 ---p 00002000 fe:01 13635416                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_padding.abi3.so
7fdcda428000-7fdcda429000 r--p 00001000 fe:01 13635416                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_padding.abi3.so
7fdcda429000-7fdcda42a000 rw-p 00002000 fe:01 13635416                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_padding.abi3.so
7fdcda42a000-7fdcda7aa000 rw-p 00000000 00:00 0 
7fdcda7aa000-7fdcda7cd000 r-xp 00000000 fe:01 13896898                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cffi-1.10.0-py3.6-linux-x86_64.egg/_cffi_backend.cpython-36m-x86_64-linux-gnu.so
7fdcda7cd000-7fdcda9cd000 ---p 00023000 fe:01 13896898                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cffi-1.10.0-py3.6-linux-x86_64.egg/_cffi_backend.cpython-36m-x86_64-linux-gnu.so
7fdcda9cd000-7fdcda9ce000 r--p 00023000 fe:01 13896898                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cffi-1.10.0-py3.6-linux-x86_64.egg/_cffi_backend.cpython-36m-x86_64-linux-gnu.so
7fdcda9ce000-7fdcda9d3000 rw-p 00024000 fe:01 13896898                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cffi-1.10.0-py3.6-linux-x86_64.egg/_cffi_backend.cpython-36m-x86_64-linux-gnu.so
7fdcda9d3000-7fdcda9d6000 rw-p 00000000 00:00 0 
7fdcda9d6000-7fdcda9d7000 r-xp 00000000 fe:01 13635417                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_constant_time.abi3.so
7fdcda9d7000-7fdcdabd7000 ---p 00001000 fe:01 13635417                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_constant_time.abi3.so
7fdcdabd7000-7fdcdabd8000 r--p 00001000 fe:01 13635417                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_constant_time.abi3.so
7fdcdabd8000-7fdcdabd9000 rw-p 00002000 fe:01 13635417                   /home/nils/src/festool/coa-pim-service/lib/python3.6/site-packages/cryptography-2.0.3-py3.6-linux-x86_64.egg/cryptography/hazmat/bindings/_constant_time.abi3.so
7fdcdabd9000-7fdcdac19000 rw-p 00000000 00:00 0 
7fdcdac3a000-7fdcdb03a000 rw-p 00000000 00:00 0 
7fdcdb03a000-7fdcdb03e000 r-xp 00000000 fe:01 6422544                    /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7fdcdb03e000-7fdcdb23d000 ---p 00004000 fe:01 6422544                    /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7fdcdb23d000-7fdcdb23e000 r--p 00003000 fe:01 6422544                    /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7fdcdb23e000-7fdcdb23f000 rw-p 00004000 fe:01 6422544                    /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7fdcdb23f000-7fdcdb246000 r-xp 00000000 fe:01 18490384                   /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7fdcdb246000-7fdcdb446000 ---p 00007000 fe:01 18490384                   /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7fdcdb446000-7fdcdb447000 r--p 00007000 fe:01 18490384                   /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7fdcdb447000-7fdcdb448000 rw-p 00008000 fe:01 18490384                   /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7fdcdb448000-7fdcdb463000 r-xp 00000000 fe:01 18757835                   /usr/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
7fdcdb463000-7fdcdb662000 ---p 0001b000 fe:01 18757835                   /usr/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
7fdcdb662000-7fdcdb663000 r--p 0001a000 fe:01 18757835                   /usr/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
7fdcdb663000-7fdcdb667000 rw-p 0001b000 fe:01 18757835                   /usr/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
7fdcdb667000-7fdcdb727000 rw-p 00000000 00:00 0 
7fdcdb727000-7fdcdb73f000 r-xp 00000000 fe:01 18753773                   /usr/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so
7fdcdb73f000-7fdcdb93e000 ---p 00018000 fe:01 18753773                   /usr/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so
7fdcdb93e000-7fdcdb93f000 r--p 00017000 fe:01 18753773                   /usr/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so
7fdcdb93f000-7fdcdb944000 rw-p 00018000 fe:01 18753773                   /usr/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so
7fdcdb944000-7fdcdba04000 rw-p 00000000 00:00 0 
7fdcdba37000-7fdcdba41000 r-xp 00000000 fe:01 18757841                   /usr/lib/python3.6/lib-dynload/_json.cpython-36m-x86_64-linux-gnu.so
7fdcdba41000-7fdcdbc40000 ---p 0000a000 fe:01 18757841                   /usr/lib/python3.6/lib-dynload/_json.cpython-36m-x86_64-linux-gnu.so
7fdcdbc40000-7fdcdbc41000 r--p 00009000 fe:01 18757841                   /usr/lib/python3.6/lib-dynload/_json.cpython-36m-x86_64-linux-gnu.so
7fdcdbc41000-7fdcdbc42000 rw-p 0000a000 fe:01 18757841                   /usr/lib/python3.6/lib-dynload/_json.cpython-36m-x86_64-linux-gnu.so
7fdcdbc42000-7fdcdbc43000 r-xp 00000000 fe:01 18753771                   /usr/lib/python3.6/lib-dynload/_opcode.cpython-36m-x86_64-linux-gnu.so
7fdcdbc43000-7fdcdbe42000 ---p 00001000 fe:01 18753771                   /usr/lib/python3.6/lib-dynload/_opcode.cpython-36m-x86_64-linux-gnu.so
7fdcdbe42000-7fdcdbe43000 r--p 00000000 fe:01 18753771                   /usr/lib/python3.6/lib-dynload/_opcode.cpython-36m-x86_64-linux-gnu.so
7fdcdbe43000-7fdcdbe44000 rw-p 00001000 fe:01 18753771                   /usr/lib/python3.6/lib-dynload/_opcode.cpython-36m-x86_64-linux-gnu.so
7fdcdbe44000-7fdcdbf84000 rw-p 00000000 00:00 0 
7fdcdbf95000-7fdcdc355000 rw-p 00000000 00:00 0 
7fdcdc355000-7fdcdc367000 r-xp 00000000 fe:01 18753772                   /usr/lib/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so
7fdcdc367000-7fdcdc566000 ---p 00012000 fe:01 18753772                   /usr/lib/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so
7fdcdc566000-7fdcdc567000 r--p 00011000 fe:01 18753772                   /usr/lib/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so
7fdcdc567000-7fdcdc569000 rw-p 00012000 fe:01 18753772                   /usr/lib/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so
7fdcdc569000-7fdcdc7ce000 r-xp 00000000 fe:01 18490325                   /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7fdcdc7ce000-7fdcdc9cd000 ---p 00265000 fe:01 18490325                   /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7fdcdc9cd000-7fdcdc9eb000 r--p 00264000 fe:01 18490325                   /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7fdcdc9eb000-7fdcdc9f9000 rw-p 00282000 fe:01 18490325                   /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7fdcdc9f9000-7fdcdc9fc000 rw-p 00000000 00:00 0 
7fdcdc9fc000-7fdcdca5e000 r-xp 00000000 fe:01 18490326                   /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7fdcdca5e000-7fdcdcc5e000 ---p 00062000 fe:01 18490326                   /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7fdcdcc5e000-7fdcdcc62000 r--p 00062000 fe:01 18490326                   /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7fdcdcc62000-7fdcdcc68000 rw-p 00066000 fe:01 18490326                   /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7fdcdcc68000-7fdcdcc6d000 r-xp 00000000 fe:01 18753770                   /usr/lib/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so
7fdcdcc6d000-7fdcdce6c000 ---p 00005000 fe:01 18753770                   /usr/lib/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so
7fdcdce6c000-7fdcdce6d000 r--p 00004000 fe:01 18753770                   /usr/lib/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so
7fdcdce6d000-7fdcdce6e000 rw-p 00005000 fe:01 18753770                   /usr/lib/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so
7fdcdce6e000-7fdcdcf2e000 rw-p 00000000 00:00 0 
7fdcdcf2e000-7fdcdcf53000 r-xp 00000000 fe:01 6422594                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7fdcdcf53000-7fdcdd152000 ---p 00025000 fe:01 6422594                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7fdcdd152000-7fdcdd153000 r--p 00024000 fe:01 6422594                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7fdcdd153000-7fdcdd154000 rw-p 00025000 fe:01 6422594                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7fdcdd154000-7fdcdd15b000 r-xp 00000000 fe:01 18757843                   /usr/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7fdcdd15b000-7fdcdd35a000 ---p 00007000 fe:01 18757843                   /usr/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7fdcdd35a000-7fdcdd35b000 r--p 00006000 fe:01 18757843                   /usr/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7fdcdd35b000-7fdcdd35d000 rw-p 00007000 fe:01 18757843                   /usr/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7fdcdd35d000-7fdcdd36c000 r-xp 00000000 fe:01 6422712                    /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7fdcdd36c000-7fdcdd56b000 ---p 0000f000 fe:01 6422712                    /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7fdcdd56b000-7fdcdd56c000 r--p 0000e000 fe:01 6422712                    /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7fdcdd56c000-7fdcdd56d000 rw-p 0000f000 fe:01 6422712                    /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7fdcdd56d000-7fdcdd571000 r-xp 00000000 fe:01 18757826                   /usr/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so
7fdcdd571000-7fdcdd770000 ---p 00004000 fe:01 18757826                   /usr/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so
7fdcdd770000-7fdcdd771000 r--p 00003000 fe:01 18757826                   /usr/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so
7fdcdd771000-7fdcdd772000 rw-p 00004000 fe:01 18757826                   /usr/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so
7fdcdd772000-7fdcdd7f2000 rw-p 00000000 00:00 0 
7fdcdd7fb000-7fdcddb3b000 rw-p 00000000 00:00 0 
7fdcddb3b000-7fdcddcd0000 r-xp 00000000 fe:01 6422647                    /lib/x86_64-linux-gnu/libc-2.24.so
7fdcddcd0000-7fdcdded0000 ---p 00195000 fe:01 6422647                    /lib/x86_64-linux-gnu/libc-2.24.so
7fdcdded0000-7fdcdded4000 r--p 00195000 fe:01 6422647                    /lib/x86_64-linux-gnu/libc-2.24.so
7fdcdded4000-7fdcdded6000 rw-p 00199000 fe:01 6422647                    /lib/x86_64-linux-gnu/libc-2.24.so
7fdcdded6000-7fdcddeda000 rw-p 00000000 00:00 0 
7fdcddeda000-7fdcddfdd000 r-xp 00000000 fe:01 6422717                    /lib/x86_64-linux-gnu/libm-2.24.so
7fdcddfdd000-7fdcde1dc000 ---p 00103000 fe:01 6422717                    /lib/x86_64-linux-gnu/libm-2.24.so
7fdcde1dc000-7fdcde1dd000 r--p 00102000 fe:01 6422717                    /lib/x86_64-linux-gnu/libm-2.24.so
7fdcde1dd000-7fdcde1de000 rw-p 00103000 fe:01 6422717                    /lib/x86_64-linux-gnu/libm-2.24.so
7fdcde1de000-7fdcde1f7000 r-xp 00000000 fe:01 6425773                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdcde1f7000-7fdcde3f6000 ---p 00019000 fe:01 6425773                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdcde3f6000-7fdcde3f7000 r--p 00018000 fe:01 6425773                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdcde3f7000-7fdcde3f8000 rw-p 00019000 fe:01 6425773                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdcde3f8000-7fdcde41f000 r-xp 00000000 fe:01 6423096                    /lib/x86_64-linux-gnu/libexpat.so.1.6.2
7fdcde41f000-7fdcde61f000 ---p 00027000 fe:01 6423096                    /lib/x86_64-linux-gnu/libexpat.so.1.6.2
7fdcde61f000-7fdcde621000 r--p 00027000 fe:01 6423096                    /lib/x86_64-linux-gnu/libexpat.so.1.6.2
7fdcde621000-7fdcde622000 rw-p 00029000 fe:01 6423096                    /lib/x86_64-linux-gnu/libexpat.so.1.6.2
7fdcde622000-7fdcde624000 r-xp 00000000 fe:01 6422935                    /lib/x86_64-linux-gnu/libutil-2.24.so
7fdcde624000-7fdcde823000 ---p 00002000 fe:01 6422935                    /lib/x86_64-linux-gnu/libutil-2.24.so
7fdcde823000-7fdcde824000 r--p 00001000 fe:01 6422935                    /lib/x86_64-linux-gnu/libutil-2.24.so
7fdcde824000-7fdcde825000 rw-p 00002000 fe:01 6422935                    /lib/x86_64-linux-gnu/libutil-2.24.so
7fdcde825000-7fdcde828000 r-xp 00000000 fe:01 6422674                    /lib/x86_64-linux-gnu/libdl-2.24.so
7fdcde828000-7fdcdea27000 ---p 00003000 fe:01 6422674                    /lib/x86_64-linux-gnu/libdl-2.24.so
7fdcdea27000-7fdcdea28000 r--p 00002000 fe:01 6422674                    /lib/x86_64-linux-gnu/libdl-2.24.so
7fdcdea28000-7fdcdea29000 rw-p 00003000 fe:01 6422674                    /lib/x86_64-linux-gnu/libdl-2.24.so
7fdcdea29000-7fdcdea41000 r-xp 00000000 fe:01 6422911                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7fdcdea41000-7fdcdec40000 ---p 00018000 fe:01 6422911                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7fdcdec40000-7fdcdec41000 r--p 00017000 fe:01 6422911                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7fdcdec41000-7fdcdec42000 rw-p 00018000 fe:01 6422911                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7fdcdec42000-7fdcdec46000 rw-p 00000000 00:00 0 
7fdcdec46000-7fdcdec69000 r-xp 00000000 fe:01 6422587                    /lib/x86_64-linux-gnu/ld-2.24.so
7fdcdec9d000-7fdcdee38000 r--p 00000000 fe:01 18502511                   /usr/lib/locale/locale-archive
7fdcdee38000-7fdcdee3c000 rw-p 00000000 00:00 0 
7fdcdee5d000-7fdcdee5e000 rw-p 00000000 00:00 0 
7fdcdee5e000-7fdcdee5f000 rwxp 00000000 00:00 0 
7fdcdee5f000-7fdcdee66000 r--s 00000000 fe:01 18513329                   /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
7fdcdee66000-7fdcdee69000 rw-p 00000000 00:00 0 
7fdcdee69000-7fdcdee6a000 r--p 00023000 fe:01 6422587                    /lib/x86_64-linux-gnu/ld-2.24.so
7fdcdee6a000-7fdcdee6b000 rw-p 00024000 fe:01 6422587                    /lib/x86_64-linux-gnu/ld-2.24.so
7fdcdee6b000-7fdcdee6c000 rw-p 00000000 00:00 0 
7ffd8f160000-7ffd8f182000 rw-p 00000000 00:00 0                          [stack]
7ffd8f1fb000-7ffd8f1fd000 r--p 00000000 00:00 0                          [vvar]
7ffd8f1fd000-7ffd8f1ff000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Abgebrochen
(coa-pim-service) nils@unknown-device:~/src/festool/coa-pim-service$ 

psycopg2 async hook

There's a pyscogreen module for installing a greenlet compatible function into pyscopg2 to get DB queries to run asynchronously. Because it's gevent (and libevent) it seems that meinheld would need it's own async monkey-patcher for pyscopg2. Just bringing it up.

Couldn't find an example to set up an external file logger for access and error logs

Hi,
I am trying to run a small flask application. Firstly I set up the logging params and then try to access.
The following method doesn't seem to be working and unfortunately I can't figure out any example where I can use an external logger for this purpose.

Any hints how can I make this work ?

import logging
def setup_logger():
    LOG_FILENAME = 'access_log.log'
    logging.getLogger('access_log').setLevel(logging.INFO)
    handler = logging.handlers.RotatingFileHandler(LOG_FILENAME,
                                                   maxBytes=1000000,
                                                   backupCount=1000)
    format = "%(asctime)s %(name)s.%(funcName)-25s %(levelname)-8s %(message)s"
    datefmt = '%Y-%m-%d %H:%M:%S'
    handler.setFormatter(logging.Formatter(format, datefmt=datefmt))
    logging.getLogger('access_log').addHandler(handler)
    print('Logging into {}'.format(LOG_FILENAME))
    return logging.getLogger('access_log')

This is how I execute my app

main.py
    meinheld.listen(("0.0.0.0", 8081))
    meinheld.set_access_logger(setup_logger())
    meinheld.set_error_logger(None)
    meinheld.run(app)

In an end point, I am trying to access this logger:

/api/endpoint
logger = logging.getLogger('access_log')
logger.info('end point hit')

Memory leak when using meinheld as gunicorn worker

Hello,

I have an application that I recently switched from gunicorn+gevent workers to gunicorn+meinheld and it is now having memory leak issues. The issues disappear when I switch back to gevent.

I haven't done much investigation at the moment because I am busy with work, but I plan on doing it later this week. Is there anything in particular I should look for to see if this is really related to meinheld?

I am using the following meinheld-related packages in the application:

greenlet==0.4.10
gunicorn==19.6.0
meinheld==0.5.9

and the following gunicorn config:

bind = '0.0.0.0:5000'
workers = 1 if current_env == 'DEV' else multiprocessing.cpu_count() * 2 + 1
worker_class = 'egg:meinheld#gunicorn_worker'
proc_name = 'api'
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" "%({X-Real-IP}i)s" %(L)s'
accesslog = '-'
errorlog = '-'

The application is basically a more complex version of this: https://github.com/admiralobvious/falcon-boilerplate

Thank you!

dnspython not send request with meinheld

Hello,

I have noticed an error when i use dnspython in django app, using meinheld backend of circus. My app use python 3.4.

My django app is lauching DNS request to check some parameters provided by users, if DNS is not correctly configured, an error is shown to users.

The following launch DNS request:

        resolver = dns.resolver.Resolver()
        resolver.nameservers = [self._get_dnshost()]
        resolver.timeout = 3
        resolver.lifetime = 3

        try:
            answers = resolver.query(self.sda.enum_format, 'NAPTR')
        except dns.exception.Timeout as e:
            raise PdnsDnsError(str(e))
        except dns.resolver.NXDOMAIN as e:
            raise PdnsDnsError(str(e))

Then, i run my app using this command:

chaussette --backend meinheld voxisdas.wsgi.application --port 8000 --host 0.0.0.0

And a dns.exception.Timeout is raised.

Do you have any clue about this error ? No DNS request is sent to my DNS server.
If i run my app with waitress for example, no error is raised. All queries are OK.

Thanks in advance.

Access log is not output when using gunicorn_worker

The following sample application is copied from README.rst and save as m.py.

from meinheld import server

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

The following log config save as logconfig.ini.

[loggers]
keys = root, gunicorn_access

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = DEBUG
handlers = console

[logger_gunicorn_access]
level = DEBUG
handlers =
propagate = 1
qualname = gunicorn.access

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s

Launch the gunicorn with meinheld's gunicorn_worker.

% gunicorn --worker-class="egg:meinheld#gunicorn_worker" --log-config logconfig.ini m:hello_world

Then access to 127.0.0.1. However, access log is not output.
And also I tried the default worker and tornado worker, They are fine.

Encoding issue while uploading file in django application

I have tested all the scenarios when my django application run without meinheld, and there is no exception.
But exceptions occurs if application is run by meinheld.

Senario 1

The uploaded file is just a text file. It is wired that I uploaded a file of size 200kb successfully. Then I copy the content of this file and paste to double its size. The exception occurred when the second file is uploaded.

I tried to debug and found that function 'meinheld.input.read' returns a str which cannot concat to bytes.

The call stack is:

Traceback (most recent call last):
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/contrib/admin/options.py", line 616, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/dev/d5_django_server/apps/product/admin.py", line 129, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/utils/decorators.py", line 34, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/utils/decorators.py", line 106, in _wrapped_view
    result = middleware.process_view(request, view_func, args, kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/middleware/csrf.py", line 174, in process_view
    request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 137, in _get_post
    self._load_post_and_files()
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/request.py", line 260, in _load_post_and_files
    self._post, self._files = self.parse_file_upload(self.META, data)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/request.py", line 225, in parse_file_upload
    return parser.parse()
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 149, in parse
    for item_type, meta_data, field_stream in Parser(stream, self._boundary):
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 626, in __iter__
    for sub_stream in boundarystream:
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 439, in __next__
    return LazyStream(BoundaryIter(self._stream, self._boundary))
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 466, in __init__
    unused_char = self._stream.read(1)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 337, in read
    out = b''.join(parts())
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 330, in parts
    chunk = next(self)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 352, in __next__
    output = next(self._producer)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 414, in __next__
    data = self.flo.read(self.chunk_size)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/request.py", line 292, in read
    return self._stream.read(*args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 57, in read
    result = self.buffer + self._read_limited(size - len(self.buffer))
TypeError: can't concat bytes to str

Senario 2

When a jpg is uploaded, the exception is different.

The call stack is:

Traceback (most recent call last):
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/contrib/admin/options.py", line 616, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/dev/d5_django_server/apps/product/admin.py", line 129, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/utils/decorators.py", line 34, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/utils/decorators.py", line 106, in _wrapped_view
    result = middleware.process_view(request, view_func, args, kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/middleware/csrf.py", line 174, in process_view
    request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 137, in _get_post
    self._load_post_and_files()
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/request.py", line 260, in _load_post_and_files
    self._post, self._files = self.parse_file_upload(self.META, data)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/request.py", line 225, in parse_file_upload
    return parser.parse()
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 149, in parse
    for item_type, meta_data, field_stream in Parser(stream, self._boundary):
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 626, in __iter__
    for sub_stream in boundarystream:
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 439, in __next__
    return LazyStream(BoundaryIter(self._stream, self._boundary))
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 466, in __init__
    unused_char = self._stream.read(1)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 337, in read
    out = b''.join(parts())
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 330, in parts
    chunk = next(self)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 352, in __next__
    output = next(self._producer)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/multipartparser.py", line 414, in __next__
    data = self.flo.read(self.chunk_size)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/http/request.py", line 292, in read
    return self._stream.read(*args, **kwargs)
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 57, in read
    result = self.buffer + self._read_limited(size - len(self.buffer))
  File "/home/dev/virtualenv/python3/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 45, in _read_limited
    result = self.stream.read(size)
  File "/home/dev/virtualenv/python3/lib/python3.4/codecs.py", line 313, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 1412: invalid start byte

Meinheld adds Transfer-Encoding header to http message 204

According to RFC2616 (see https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4), messages without a body (like 204) are "always terminated by the first empty line after the header fields". So there is no "Content-Length" header necessary.

Further, RFC7230 states: "A server MUST NOT send a Transfer-Encoding header field in any response with a status code of 1xx (Informational) or 204 (No Content)." (see https://tools.ietf.org/html/rfc7230#section-3.3.1)

In my setup (Meinheld 0.6.1 + Pyramid 1.7.3), meinheld adds a "Transfer-Encoding: chunked" header even to HTTP 204 responses, which leads to problems with clients (curl, for example) waiting for additional content (a terminating CRLF for the chunked encoding), while there is an empty body. A temporary workaround for me is to add a "Content-Length: 0" header on my own for those responses, so they don't get the wrong Transfer-Encoding header.

The bugs seems to be in the server/response.c - something from this part:

// check content_length_set
if(data && !client->content_length_set && client->http_parser->http_minor == 1){
    //Transfer-Encoding chunked
    add_header(bucket, "Transfer-Encoding", 17, "chunked", 7);
    client->chunked_response = 1;
}

multiple sockets support

Gunicorn is now able to bind multiples interfaces and now pass a list of sockets to the worker. Meinheld api is currently only able to listen on one socket and won't work with the coming version.

I had a quick look on it an dit seems that having the method server.set_listen_sockettaking a list and adding all fds in the run function of server.c would be enough. I will try to fix that over the week-end but it maybe faster if the change come from you I guess :)

Override global header

Can I override the header "Server"?

I am using Python Bottle with Meinheld. Is it possible to override it?

Thanks

Handle async file upload?

I saw in uploads.py example, but it seem not async. When file is uploading, server block all other requests :(

Suggest disable access logging by default

I have a small bottle based web app managing my raspberry pi home alarm system and did some primitive bench marking of all the many bottle supported web servers using ab. Bjoern does not log requests and it came out significantly on top with 133 requests/sec. Meinheld was about 1/2 this rate. However if I disable logging with meinheld.set_access_logger(None) and set_error_logger(None) then meinheld performs essentially same as bjoern, much faster than all the other servers.

I wonder why you don't disable logging by default, given the performance implications? Just a suggestion.

msocket.py setsockopt error

  • python 2.7.12
  • meinheld 0.6.1

POC

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from meinheld import patch
patch.patch_all()
from logging.handlers import SysLogHandler

SysLogHandler({'address': ('127.0.0.1', 5140)})

Result

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    SysLogHandler({'address': ('127.0.0.1', 5140)})
  File "/opt/python27/lib/python2.7/logging/handlers.py", line 766, in __init__
    self.socket = socket.socket(socket.AF_INET, socktype)
  File "/opt/python27/lib/python2.7/site-packages/meinheld/msocket.py", line 524, in __init__
    self.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
  File "<string>", line 1, in setsockopt
socket.error: [Errno 92] Protocol not available

IPPROTO_TCP, TCP_NODELAY is not imported.

meinheld doesn't like weberror

WebError is a WSGI app, with email notification. But handlers don't work with
meinheld.

Inside WebError WSGI call pipeline (weberror/errormiddleware.py),
an exception occured during response creation. This exception occured before
handler's call. That's why it cannot send email ...

this is a snippet of errormiddleware (weberror module)

         exc_info = sys.exc_info()
         try:
             start_response('500 Internal Server Error',
                            [('content-type', 'text/html; 
                            charset=utf8')],
                            exc_info)
             response = self.exception_handler(exc_info, environ)
             # @@: it would be nice to deal with bad content types here
             if isinstance(response, unicode):
                 response = response.encode('utf8')
             return [response]

The exception occured on start_response('500 ...)
start_response is a method of .c meinheld part. It seems that
meinheld/server/response.c don't support response creation with
sys.exc_info() argument. In such occasion meinheld catch everything, write
the previous exception in standard output and return it's own 500 response

this bug is easy to reproduce. easy_install meinheld, pyramid, weberror
create a view with a bug and use weberror

Full pipeline support.

Currently, stop reading next request while processing request.
epoll_ctl() is called to stop and start reading.

To reduce epoll_ctl(), permit reading while processing request.

Disable access and error logging for benchmarking

How can I disbale all access and error logging from my code below.
Thanks :)

from meinheld import patch
patch.patch_all()
app = bottle.Bottle()
@app.route('/')
def main():
return 'hello'
bottle.run(app, host='0.0.0.0', port=8080, server='meinheld')

greenlet 0.4.5 breaks meinheld

There are many greenlet errors like this:

Current thread 0x00007fff796de310 (most recent call first):
Exception ignored in: <greenlet.greenlet object at 0x1033816d0>
greenlet.error: cannot switch to a garbage collected greenlet
Fatal Python error: greenlets cannot continue

When using with greenlet 0.4.4, it doesn't happen.

WebSocket

Is the WebSocket middleware stable for production use and web socket spec. compliant?

websocket whith gunicorn

hi, how too run WebSocketMiddleware whith gunicorn? when i start running server on gunicorn ,websocket server can't global participants , need help -.-

Meinheld coredump

My Python 3 app core dumped yesterday on a Raspberry Pi 2 running Arch Arm. Versions and coredump details are below.

pi2:~ uname -a
Linux pi2 4.9.43-1-ARCH #1 SMP Fri Aug 18 01:10:29 UTC 2017 armv7l GNU/Linux

pi2:~ python --version
Python 3.6.2

pi2:~ ~/Data/src/pialarm/env/bin/pip list --format=legacy
Beaker (1.9.0)
bottle (0.12.13)
bottle-cork (0.12.0)
greenlet (0.4.12)
meinheld (0.6.1)
pifaceio (1.26)
pip (9.0.1)
pycrypto (2.6.1)
ruamel.yaml (0.15.32)
setuptools (28.8.0)

pi2:~ coredumpctl gdb
           PID: 266 (pialarm)
           UID: 1000 (pi)
           GID: 1000 (pi)
        Signal: 11 (SEGV)
     Timestamp: Fri 2017-08-25 07:56:07 AEST (24h ago)
  Command Line: env/bin/python -u /home/pi/Data/src/pialarm/pialarm
    Executable: /usr/bin/python3.6
 Control Group: /system.slice/pialarm.service
          Unit: pialarm.service
         Slice: system.slice
       Boot ID: c1da2280d845469d8f3d91fe7252c78d
    Machine ID: d248d73f28ea419a864101496b8fce31
      Hostname: pi2
       Storage: /var/lib/systemd/coredump/core.pialarm.1000.c1da2280d845469d8f3d91fe7252c78d.266.1503611767000000.lz4
       Message: Process 266 (pialarm) of user 1000 dumped core.
                
                Stack trace of thread 266:
                #0  0x0000000074864d84 n/a (/home/pi/Data/src/pialarm/env/lib/python3.6/site-packages/meinheld/server.cpython-36m-arm-linux-gnueabihf.so)

GNU gdb (GDB) 8.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7l-unknown-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/python3.6...(no debugging symbols found)...done.

warning: core file may not match specified executable file.
[New LWP 266]
[New LWP 350]
[New LWP 352]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `env/bin/python -u /home/pi/Data/src/pialarm/pialarm'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  import_greenlet () at meinheld/server/greensupport.c:15
15	meinheld/server/greensupport.c: No such file or directory.
[Current thread is 1 (Thread 0x76f4d010 (LWP 266))]
(gdb) where
#0  import_greenlet () at meinheld/server/greensupport.c:15
#1  greenlet_new (o=0x748d10d0, parent=0x0)
    at meinheld/server/greensupport.c:31
#2  0x7485875c in call_wsgi_handler (client=<optimized out>)
    at meinheld/server/server.c:716
#3  0x7485b61c in accept_callback (loop=0x181bf00, fd=4, 
    events=<optimized out>, cb_arg=<optimized out>)
    at meinheld/server/server.c:1272
#4  0x74865b30 in picoev_poll_once_internal (_loop=_loop@entry=0x181bf00, 
    max_wait=<optimized out>) at meinheld/server/picoev_epoll.c:174
#5  0x7485c500 in picoev_loop_once (max_wait=<optimized out>, loop=0x181bf00)
    at meinheld/server/picoev.h:390
#6  meinheld_run_loop (self=<optimized out>, args=<optimized out>, 
    kwds=<optimized out>) at meinheld/server/server.c:1853
#7  0x76cbdb18 in _PyCFunction_FastCallDict ()
   from /usr/lib/libpython3.6m.so.1.0
#8  0x76d881e4 in ?? () from /usr/lib/libpython3.6m.so.1.0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

Occurred after updating system and rebooting but unfortunately I can not repeat the crash so seems just a one-off atm. I am raising this issue so it is known about. This app has been running for many years although I frequently update system and PyPI packages though.

Problem in django-chat

Well, I test meinheld in my system, but it seems like django-chat can't be runing in chrome. However, the same example with gevent was working well.

Segmentation fault when attack with wrk-pipeline

OS: Ubuntu 13.04
Python 2.7.4

How to reproduce.

  1. Run this bottle app with gunicorn/meinheld.
  2. /wrk-pipeline -c8 -d3600 -t2 http://127.0.0.1:8080/json
picoev_set_timeout (secs=2, fd=1115, loop=0x2ea3a60) at meinheld/server/picoev.h:209
209           vec[vi] |= (unsigned short)SHRT_MIN >> (fd % PICOEV_SHORT_BITS);
(gdb) bt
#0  picoev_set_timeout (secs=2, fd=1115, loop=0x2ea3a60) at meinheld/server/picoev.h:209
#1  picoev_add (cb_arg=0x31c5550, callback=0x7fac4f997c00 <read_callback>, timeout_in_secs=<optimized out>, events=1, fd=<optimized out>, loop=0x2ea3a60)
    at meinheld/server/picoev.h:233
#2  close_client (client=0x2cf4250) at meinheld/server/server.c:395
#3  0x00007fac4f998112 in app_handler (self=<optimized out>, args=<optimized out>) at meinheld/server/server.c:582
#4  0x000000000049f82d in PyEval_CallObjectWithKeywords ()
#5  0x00007fac4e1f2949 in g_initialstub (mark=mark@entry=0x7fffd2bd6f48) at greenlet.c:804
#6  0x00007fac4e1f2380 in g_switch (target=target@entry=0x2884a50, args=args@entry=0x7fac5291a050, kwargs=kwargs@entry=0x0) at greenlet.c:576
#7  0x00007fac4e1f3213 in PyGreenlet_Switch (g=0x2884a50, args=0x7fac5291a050, kwargs=0x0) at greenlet.c:1395
#8  0x00007fac4f995496 in call_wsgi_handler (client=<optimized out>) at meinheld/server/server.c:709
#9  0x00007fac4f9988e9 in accept_callback (loop=0x2ea3a60, fd=6, events=<optimized out>, cb_arg=<optimized out>) at meinheld/server/server.c:1259
#10 0x00007fac4f99ac22 in picoev_poll_once_internal (_loop=_loop@entry=0x2ea3a60, max_wait=<optimized out>) at meinheld/server/picoev_epoll.c:160
#11 0x00007fac4f999111 in picoev_loop_once (loop=0x2ea3a60, max_wait=<optimized out>) at meinheld/server/picoev.h:388
#12 meinheld_run_loop (self=<optimized out>, args=<optimized out>, kwds=<optimized out>) at meinheld/server/server.c:1839
(gdb) list
204             delta = PICOEV_TIMEOUT_VEC_SIZE - 1;
205           }
206           target->timeout_idx =
207             (loop->timeout.base_idx + delta) % PICOEV_TIMEOUT_VEC_SIZE;
208           vec = PICOEV_TIMEOUT_VEC_OF(loop, target->timeout_idx);
209           vec[vi] |= (unsigned short)SHRT_MIN >> (fd % PICOEV_SHORT_BITS);
210           vec_of_vec = PICOEV_TIMEOUT_VEC_OF_VEC_OF(loop, target->timeout_idx);
211           vec_of_vec[vi / PICOEV_SHORT_BITS]
212             |= (unsigned short)SHRT_MIN >> (vi % PICOEV_SHORT_BITS);
213         }
(gdb) print vi
$1 = 69
(gdb) print vec
$2 = <optimized out>
(gdb) print loop
$3 = (picoev_loop *) 0x2ea3a60
(gdb) print *loop
Cannot access memory at address 0x2ea3a60

Make FileWrapperObject iterable

To be compatible with Werkzeug's integrated debugger the FileWrapperObject must be iterable. I created a patch. Well, it's not that good since I don't know the Python-C-API that much but it works properly. It's just a wrapper around the filelike object.

http://paste.pocoo.org/show/244490/

Regards,
Christopher.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.