Skip to content

Fix a possible race condition in sslproto test #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions tests/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2870,8 +2870,11 @@ async def client(addr, ctx):
self.assertIsNone(ctx())

def test_shutdown_timeout_handler_not_set(self):
if self.implementation == 'asyncio':
# asyncio doesn't call SSL eof_received() so we can't run this test
raise unittest.SkipTest()

loop = self.loop
eof = asyncio.Event()
extra = None

def server(sock):
Expand All @@ -2883,7 +2886,6 @@ def server(sock):
sock.send(b'extra bytes')
# sending EOF here
sock.shutdown(socket.SHUT_WR)
loop.call_soon_threadsafe(eof.set)
# make sure we have enough time to reproduce the issue
self.assertEqual(sock.recv(1024), b'')
sock.close()
Expand Down Expand Up @@ -2911,17 +2913,16 @@ def connection_lost(self, exc):
else:
self.fut.set_exception(exc)

def eof_received(self):
self.transport.resume_reading()

async def client(addr):
ctx = self._create_client_ssl_context()
tr, pr = await loop.create_connection(Protocol, *addr, ssl=ctx)
await eof.wait()
tr.resume_reading()
await pr.fut
tr.close()
if self.implementation != 'asyncio':
# extra data received after transport.close() should be
# ignored - this is likely a bug in asyncio
self.assertIsNone(extra)
# extra data received after transport.close() should be ignored
self.assertIsNone(extra)

with self.tcp_server(server) as srv:
loop.run_until_complete(client(srv.addr))
Expand Down