[Python-checkins] bpo-35602: Make sure the transport is always closed in SelectorEventLoopUnixSockSendfileTests (GH-11338)
Miss Islington (bot)
webhook-mailer at python.org
Sat Dec 29 14:38:26 EST 2018
https://github.com/python/cpython/commit/fe06646d186780881fa5ee61442886a6d7cf9f08
commit: fe06646d186780881fa5ee61442886a6d7cf9f08
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-12-29T11:38:24-08:00
summary:
bpo-35602: Make sure the transport is always closed in SelectorEventLoopUnixSockSendfileTests (GH-11338)
There is a race condition in SelectorEventLoopUnixSockSendfileTests that causes the prepare() method return a non connected server protocol, making the cleanup() method skips the correct handling of the transport. This commit makes prepare() always return a connected server protocol that can always be cleaned up correctly.
(cherry picked from commit d51324a2f5d172665f8824b25456c9822797fc84)
Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>
files:
M Lib/test/test_asyncio/test_unix_events.py
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 104f99593797..5d16b95456f0 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -433,10 +433,12 @@ def __init__(self, loop):
self.data = bytearray()
self.fut = loop.create_future()
self.transport = None
+ self._ready = loop.create_future()
def connection_made(self, transport):
self.started = True
self.transport = transport
+ self._ready.set_result(None)
def data_received(self, data):
self.data.extend(data)
@@ -487,13 +489,11 @@ def prepare(self):
server = self.run_loop(self.loop.create_server(
lambda: proto, sock=srv_sock))
self.run_loop(self.loop.sock_connect(sock, (support.HOST, port)))
+ self.run_loop(proto._ready)
def cleanup():
- if proto.transport is not None:
- # can be None if the task was cancelled before
- # connection_made callback
- proto.transport.close()
- self.run_loop(proto.wait_closed())
+ proto.transport.close()
+ self.run_loop(proto.wait_closed())
server.close()
self.run_loop(server.wait_closed())
More information about the Python-checkins
mailing list