Commit 9e651ded authored by Yury Selivanov's avatar Yury Selivanov

Update curio

parent 3728d87c
......@@ -2,7 +2,7 @@
# A simple echo server
from curio import Kernel, new_task, run_server
from curio import run, tcp_server
from socket import *
......@@ -14,12 +14,11 @@ async def echo_handler(client, addr):
pass
while True:
data = await client.recv(102400)
data = await client.recv(1000000)
if not data:
break
await client.sendall(data)
print('Connection closed')
if __name__ == '__main__':
kernel = Kernel()
kernel.run(run_server('', 25000, echo_handler))
run(tcp_server('', 25000, echo_handler))
from curio import Kernel, new_task, run_server
from curio import run, spawn, tcp_server
from socket import *
async def echo_handler(client, addr):
......@@ -7,16 +7,15 @@ async def echo_handler(client, addr):
client.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
except (OSError, NameError):
pass
reader, writer = client.make_streams()
async with reader, writer:
s = client.as_stream()
while True:
data = await reader.read(102400)
data = await s.read(102400)
if not data:
break
await writer.write(data)
await client.close()
await s.write(data)
await s.close()
print('Connection closed')
if __name__ == '__main__':
kernel = Kernel()
kernel.run(run_server('', 25000, echo_handler))
run(tcp_server('', 25000, echo_handler))
curio==0.1
curio==0.4
aiohttp==0.21.5
gevent==1.1.1
tornado==4.3
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment