Skip to content

Commit 96ae80f

Browse files
pythongh-98703: Add tests for closing _ProactorSocketTransport with proactor event loop (pythonGH-98730)
1 parent 8a75542 commit 96ae80f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Lib/test/test_asyncio/test_proactor_events.py

+21
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,27 @@ def test_force_close_idempotent(self):
297297
# and waiters will never be notified leading to hang.
298298
self.assertTrue(self.protocol.connection_lost.called)
299299

300+
def test_force_close_protocol_connection_lost_once(self):
301+
tr = self.socket_transport()
302+
self.assertFalse(self.protocol.connection_lost.called)
303+
tr._closing = True
304+
# Calling _force_close twice should not call
305+
# protocol.connection_lost twice
306+
tr._force_close(None)
307+
tr._force_close(None)
308+
test_utils.run_briefly(self.loop)
309+
self.assertEqual(1, self.protocol.connection_lost.call_count)
310+
311+
def test_close_protocol_connection_lost_once(self):
312+
tr = self.socket_transport()
313+
self.assertFalse(self.protocol.connection_lost.called)
314+
# Calling close twice should not call
315+
# protocol.connection_lost twice
316+
tr.close()
317+
tr.close()
318+
test_utils.run_briefly(self.loop)
319+
self.assertEqual(1, self.protocol.connection_lost.call_count)
320+
300321
def test_fatal_error_2(self):
301322
tr = self.socket_transport()
302323
tr._buffer = [b'data']

0 commit comments

Comments
 (0)