DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
код, который не демонÑтрирует ожидавшегоÑÑ Ð°Ñинхронного поведениÑ
// ÑоглаÑно информации отÑюда: http://bottlepy.org/docs/dev/async.html, ожидалоÑÑŒ, что данный код будет демонÑтрировать аÑинчхронное поведение, что оказалоÑÑŒ не правдой. UPDATE: проблема решена. Дело в том, что "Some browsers buffer a certain amount of data before they start rendering a page. You might need to yield more than a few bytes to see an effect in these browsers."
from gevent.pywsgi import WSGIServer
import gevent
from gevent import monkey; monkey.patch_all()
def hello_world(env, start_response):
#import ipdb; ipdb.set_trace()
if env['PATH_INFO'] == '/':
start_response('200 OK', [('Content-Type', 'text/html')])
yield 'qwerty'
gevent.sleep(5)
yield "<b>hello world</b>"
else:
start_response('404 Not Found', [('Content-Type', 'text/html')])
yield '<h1>Not Found</h1>'
print 'Serving on 8088...'
WSGIServer(('', 8088), hello_world).serve_forever()





