Commit 2e6b35dc authored by Denis Bilenko's avatar Denis Bilenko

fix examples/echoserver.py

parent 641c551b
...@@ -32,14 +32,14 @@ and then 'quit') ...@@ -32,14 +32,14 @@ and then 'quit')
import gevent import gevent
from gevent import socket from gevent import socket
def handle_socket(reader, writer): def handle_socket(f):
print "client connected"
while True: while True:
# pass through every non-eof line x = f.readline()
x = reader.readline() if not x:
if not x: break break
writer.write(x) f.write(x)
print "echoed", x f.flush()
print "echoed", repr(x)
print "client disconnected" print "client disconnected"
if __name__ == '__main__': if __name__ == '__main__':
...@@ -51,4 +51,4 @@ if __name__ == '__main__': ...@@ -51,4 +51,4 @@ if __name__ == '__main__':
except KeyboardInterrupt: except KeyboardInterrupt:
break break
# handle every new connection with a new coroutine # handle every new connection with a new coroutine
gevent.spawn(handle_socket, new_sock.makefile('r'), new_sock.makefile('w')) gevent.spawn(handle_socket, new_sock.makefile())
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