unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.46k stars 692 forks source link

--http11-socket doesn't work with --gevent #1964

Open zhanp opened 5 years ago

zhanp commented 5 years ago

I try to run a super simple flask server with --http11-socket and --gevent and failed.

I run with this command:

uwsgi -w wsgi --http11-socket :5000 -M --workers 2 --gevent 10 --gevent-monkey-patch

And my demo server:

from flask import Flask

application = Flask(__name__)

@application.route("/")
def hello():
    return "Hello World!"

Attach my dependence:

uWSGI==2.0.17.1
gevent==1.4.0
Flask==1.0.2

I can start up my server, but when I tried to test the Keep-Alive support, the second request blocked and the third request triggered the second request fail.

import requests

s = requests.session()
s.get('http://localhost:5000')  # second time will block

I got some log.

[pid: 41413|app: 0|req: 1/1] 127.0.0.1 () {32 vars in 425 bytes} [Thu Jan 17 16:29:40 2019] GET / => generated 12 bytes in 2 msecs (HTTP/1.1 200) 2 headers in 79 bytes (3 switches on core 9)
Traceback (most recent call last):
  File "src/gevent/_greenlet_primitives.py", line 60, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 63, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 66, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch_out
  File "src/gevent/_greenlet_primitives.py", line 67, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch_out
BlockingSwitchOutError: Impossible to call blocking function in the event loop callback
2019-01-17T08:29:44Z
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 711, in gevent._greenlet.Greenlet.join
  File "src/gevent/greenlet.py", line 737, in gevent._greenlet.Greenlet.join
  File "src/gevent/greenlet.py", line 726, in gevent._greenlet.Greenlet.join
  File "src/gevent/_greenlet_primitives.py", line 60, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 64, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/__greenlet_primitives.pxd", line 35, in gevent.__greenlet_primitives._greenlet_switch
gevent.exceptions.BlockingSwitchOutError: Impossible to call blocking function in the event loop callback
[pid: 41414|app: 0|req: 1/2] 127.0.0.1 () {32 vars in 425 bytes} [Thu Jan 17 16:29:44 2019] GET / => generated 12 bytes in 6 msecs (HTTP/1.1 200) 2 headers in 79 bytes (3 switches on core 9)
AriaLyy commented 5 years ago

I am using the docker container and I am having the same problem