I've taken sample code from Unterstanding eventlet.wsgi.server.
from eventlet import wsgi
import eventlet
from eventlet.green import time
import threading
def hello_world(env, start_response):
print "got request", eventlet.greenthread.getcurrent(), threading.currentThread()
time.sleep(10)
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello, World!\n']
wsgi.server(eventlet.listen(('', 8090)), hello_world)
When I access the web server via different client ip addresses, I can see they are processed in parallel. And with the print in hello_world
, I can also that they are processed in two different greenthreads but in same OS thread.
I'm new to Python. I'm curious that if each greenthread ties to an underlying OS thread?