[Python-checkins] cpython: asyncio doc: simplify ping example, remove the useless timeout

victor.stinner python-checkins at python.org
Tue Dec 3 15:06:05 CET 2013


http://hg.python.org/cpython/rev/9fc428162cbd
changeset: 87741:9fc428162cbd
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Dec 03 15:04:18 2013 +0100
summary:
 asyncio doc: simplify ping example, remove the useless timeout
files:
 Doc/library/asyncio-protocol.rst | 10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst
--- a/Doc/library/asyncio-protocol.rst
+++ b/Doc/library/asyncio-protocol.rst
@@ -589,25 +589,21 @@
 import asyncio
 
 class EchoServer(asyncio.Protocol):
- def timeout(self):
- print('connection timeout, closing.')
- self.transport.close()
-
 def connection_made(self, transport):
 print('connection made')
 self.transport = transport
 
- # close the client connection after 2 seconds
- asyncio.get_event_loop().call_later(2.0, self.timeout)
 
 def data_received(self, data):
 print('data received:', data.decode())
 self.transport.write(data)
 
+ # close the socket
+ self.transport.close()
+
 def connection_lost(self, exc):
 print('connection lost')
 
-
 loop = asyncio.get_event_loop()
 f = loop.create_server(EchoServer, '127.0.0.1', 8888)
 s = loop.run_until_complete(f)
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /