Skip to content

Commit 070753d

Browse files
itamarometa-codesync[bot]
authored andcommitted
test_asyncio.test_ssl: fix slow-socket transport race
Summary: test_remote_shutdown_receives_trailing_data_on_slow_socket reads `writer.transport._ssl_protocol._transport` and wraps its `write`. On a slow / loaded socket the remote shutdown can complete first, and connection_lost clears `_ssl_protocol._transport` to None, so the test raised `AttributeError: 'NoneType' object has no attribute 'write'`. Bail out of the delayed-write-path check when the underlying transport is already gone. Reviewed By: Yhg1s Differential Revision: D108567107 fbshipit-source-id: e06835bc46be1183c89aec21b04f693090d6aff4
1 parent 01489b0 commit 070753d

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_asyncio/test_ssl.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,13 @@ async def client(addr):
15441544
# This triggers bug gh-115514, also tested using mocks in
15451545
# test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_buffer_after_close
15461546
socket_transport = writer.transport._ssl_protocol._transport
1547+
if socket_transport is None:
1548+
# On a slow socket the remote shutdown may have already torn
1549+
# down the underlying transport (connection_lost clears
1550+
# _ssl_protocol._transport) before we get here. The delayed
1551+
# write path exercised below is then moot, so skip it instead
1552+
# of dereferencing None.
1553+
return
15471554

15481555
class SocketWrapper:
15491556
def __init__(self, sock) -> None:

0 commit comments

Comments
 (0)