summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_streams.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-07-25 00:40:40 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-07-25 00:40:40 (GMT)
commiteaf16abc68a09e2d976c37e34eb606f5b519f7ea (patch)
treed9440e1c79b158094e71c1238407ca5f7a7cdcfb /Lib/test/test_asyncio/test_streams.py
parent71080fc3518e2d3555f555340c3e93f3b108a5b8 (diff)
downloadcpython-eaf16abc68a09e2d976c37e34eb606f5b519f7ea.zip
cpython-eaf16abc68a09e2d976c37e34eb606f5b519f7ea.tar.gz
cpython-eaf16abc68a09e2d976c37e34eb606f5b519f7ea.tar.bz2
asyncio: sync with github
* Fix ResourceWarning warnings in test_streams * Return True from StreamReader.eof_received() to fix http://bugs.python.org/issue24539 (but still needs a unittest). Add StreamReader.__repr__() for easy debugging. * remove unused imports * Issue #234: Drop JoinableQueue on Python 3.5+
Diffstat (limited to 'Lib/test/test_asyncio/test_streams.py')
-rw-r--r--Lib/test/test_asyncio/test_streams.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py
index 242b377..ef6f603 100644
--- a/Lib/test/test_asyncio/test_streams.py
+++ b/Lib/test/test_asyncio/test_streams.py
@@ -446,6 +446,8 @@ class StreamReaderTests(test_utils.TestCase):
def handle_client(self, client_reader, client_writer):
data = yield from client_reader.readline()
client_writer.write(data)
+ yield from client_writer.drain()
+ client_writer.close()
def start(self):
sock = socket.socket()
@@ -457,12 +459,8 @@ class StreamReaderTests(test_utils.TestCase):
return sock.getsockname()
def handle_client_callback(self, client_reader, client_writer):
- task = asyncio.Task(client_reader.readline(), loop=self.loop)
-
- def done(task):
- client_writer.write(task.result())
-
- task.add_done_callback(done)
+ self.loop.create_task(self.handle_client(client_reader,
+ client_writer))
def start_callback(self):
sock = socket.socket()
@@ -522,6 +520,8 @@ class StreamReaderTests(test_utils.TestCase):
def handle_client(self, client_reader, client_writer):
data = yield from client_reader.readline()
client_writer.write(data)
+ yield from client_writer.drain()
+ client_writer.close()
def start(self):
self.server = self.loop.run_until_complete(
@@ -530,18 +530,14 @@ class StreamReaderTests(test_utils.TestCase):
loop=self.loop))
def handle_client_callback(self, client_reader, client_writer):
- task = asyncio.Task(client_reader.readline(), loop=self.loop)
-
- def done(task):
- client_writer.write(task.result())
-
- task.add_done_callback(done)
+ self.loop.create_task(self.handle_client(client_reader,
+ client_writer))
def start_callback(self):
- self.server = self.loop.run_until_complete(
- asyncio.start_unix_server(self.handle_client_callback,
- path=self.path,
- loop=self.loop))
+ start = asyncio.start_unix_server(self.handle_client_callback,
+ path=self.path,
+ loop=self.loop)
+ self.server = self.loop.run_until_complete(start)
def stop(self):
if self.server is not None: