Ho preso il codice di esempio da Unterstanding eventlet.wsgi.server.È un greenthread uguale a un thread "reale"
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)
Quando accedo al server Web tramite diversi indirizzi IP client, posso vedere che vengono elaborati in parallelo. E con la stampa in hello_world
, posso anche che vengano elaborati in due greenthread diversi ma nello stesso thread del sistema operativo.
Sono nuovo di Python. Sono curioso che se ogni greenthread si lega a un thread OS sottostante?
fili verdi non si basano su alcun nativo Funzionalità del sistema operativo e vengono gestite nello spazio utente anziché nello spazio del kernel – Chipmunk