uasyncio/benchmark: Add "medium load" server, serving 12K output per request.

pull/33/merge
Paul Sokolovsky 2015-06-21 02:01:45 +03:00
rodzic 68b30061bc
commit 1251e83b6c
1 zmienionych plików z 22 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,22 @@
import uasyncio as asyncio
resp = "HTTP/1.0 200 OK\r\n\r\n" + "Hello.\r\n" * 1500
@asyncio.coroutine
def serve(reader, writer):
#print(reader, writer)
#print("================")
yield from reader.read(256)
yield from writer.awrite(resp)
yield from writer.aclose()
#print("Finished processing request")
import logging
#logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()
#mem_info()
loop.create_task(asyncio.start_server(serve, "127.0.0.1", 8081, backlog=100))
loop.run_forever()
loop.close()