summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/test_selector_events.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-09-15 14:13:15 -0400
committerYury Selivanov <yury@magic.io>2016-09-15 14:13:15 -0400
commita1b0e7db7315ff0d8d0f8edc056f387f198cf5a1 (patch)
treefec197b937b7573fb1558aa9ce4e6b0d75557f24 /Lib/test/test_asyncio/test_selector_events.py
parent4357cf62028964eb1a56c503ec1296de3034b77b (diff)
downloadcpython-git-a1b0e7db7315ff0d8d0f8edc056f387f198cf5a1.tar.gz
Issue #27906: Fix socket accept exhaustion during high TCP traffic.
Patch by Kevin Conway.
Diffstat (limited to 'Lib/test/test_asyncio/test_selector_events.py')
-rw-r--r--Lib/test/test_asyncio/test_selector_events.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
index ff71c218bb..73bc3f3281 100644
--- a/Lib/test/test_asyncio/test_selector_events.py
+++ b/Lib/test/test_asyncio/test_selector_events.py
@@ -687,6 +687,20 @@ class BaseSelectorEventLoopTests(test_utils.TestCase):
selectors.EVENT_WRITE)])
self.loop.remove_writer.assert_called_with(1)
+ def test_accept_connection_multiple(self):
+ sock = mock.Mock()
+ sock.accept.return_value = (mock.Mock(), mock.Mock())
+ backlog = 100
+ # Mock the coroutine generation for a connection to prevent
+ # warnings related to un-awaited coroutines.
+ mock_obj = mock.patch.object
+ with mock_obj(self.loop, '_accept_connection2') as accept2_mock:
+ accept2_mock.return_value = None
+ with mock_obj(self.loop, 'create_task') as task_mock:
+ task_mock.return_value = None
+ self.loop._accept_connection(mock.Mock(), sock, backlog=backlog)
+ self.assertEqual(sock.accept.call_count, backlog)
+
class SelectorTransportTests(test_utils.TestCase):