Skip to content
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

gh-98703: add tests for closing _ProactorSocketTransport with proactor event loop #98730

Merged
merged 2 commits into from
Oct 27, 2022
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
21 changes: 21 additions & 0 deletions Lib/test/test_asyncio/test_proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,27 @@ def test_force_close_idempotent(self):
# and waiters will never be notified leading to hang.
self.assertTrue(self.protocol.connection_lost.called)

def test_force_close_protocol_connection_lost_once(self):
tr = self.socket_transport()
self.assertFalse(self.protocol.connection_lost.called)
tr._closing = True
# Calling _force_close twice should not call
# protocol.connection_lost twice
tr._force_close(None)
tr._force_close(None)
test_utils.run_briefly(self.loop)
self.assertEqual(1, self.protocol.connection_lost.call_count)

def test_close_protocol_connection_lost_once(self):
tr = self.socket_transport()
self.assertFalse(self.protocol.connection_lost.called)
# Calling close twice should not call
# protocol.connection_lost twice
tr.close()
tr.close()
test_utils.run_briefly(self.loop)
self.assertEqual(1, self.protocol.connection_lost.call_count)

def test_fatal_error_2(self):
tr = self.socket_transport()
tr._buffer = [b'data']
Expand Down