mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
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+
This commit is contained in:
parent
71080fc351
commit
eaf16abc68
7 changed files with 37 additions and 28 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue