summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_unix_events.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2018-12-29 19:18:38 (GMT)
committerGitHub <noreply@github.com>2018-12-29 19:18:38 (GMT)
commitd51324a2f5d172665f8824b25456c9822797fc84 (patch)
treead44678a5157310525c5e3f8b5d43f747aec1612 /Lib/test/test_asyncio/test_unix_events.py
parent78de01198b047347abc5e458851bb12c48429e24 (diff)
downloadcpython-d51324a2f5d172665f8824b25456c9822797fc84.zip
cpython-d51324a2f5d172665f8824b25456c9822797fc84.tar.gz
cpython-d51324a2f5d172665f8824b25456c9822797fc84.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_asyncio/test_unix_events.py')
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 62545c0..31e7100 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -449,10 +449,12 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
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)
@@ -503,13 +505,11 @@ class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):
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())