2

I have this simple Python programm:

from eventlet import wsgi
import eventlet
from eventlet.green import time

def hello_world(env, start_response):
    print "got request"
    time.sleep(10)
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello, World!\n']

wsgi.server(eventlet.listen(('', 8090)), hello_world)

So when i run it, and open http://localhost:8090/ on my browser multiple times, got request is only printed after the first request was already processed (after 10 seconds). It seems like eventlet.wsgi.server is processing the requests synchronously. But I am using the "green" sleep. sow how can this happen?

Thank you!

ihucos
  • 1,821
  • 3
  • 19
  • 30
  • i took a look at `wsgi.py` every request is processed on a seperate (green) thread `pool.spawn_n(serv.process_request, client_socket)` and the pool maxium size is 1024... – ihucos Dec 14 '11 at 18:13
  • are you sure you have unbuffered output ? – ionelmc Dec 15 '11 at 12:59
  • do yo know how i can check this? – ihucos Dec 15 '11 at 19:15
  • You can run python in unbuffered mode (python -u) and there's also the PYTHONUNBUFFERED=x enviroment var you could set. – ionelmc Dec 17 '11 at 13:06
  • its funny, but my main application is working well, but this simple test not, anyway... thank you for the help! – ihucos Dec 22 '11 at 03:08
  • 1
    I can confirm the problem exist, don't know the answer, yet I observed more clue. The problem seems relative to the client IP! Because if you open your browser to visit `http://localhost:8090` and `http://192.168.1.2:8090`, both quickly trigger the **got request** message. However if you fire up more requests, they wait until the first two finish. Note: Here I assume your machine's ip is 192.168.1.2 – RayLuo Jan 03 '13 at 14:10

1 Answers1

1

You have to use the monkey patch as below:

eventlet.patcher.monkey_patch(all=False, socket=True, time=True,
                          select=True, thread=True, os=True)

More information could be found from this link.

Shuai Fang
  • 11
  • 2