Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-90871: fix connection backlog offset in asyncio#134392

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 13 commits intopython:mainfromChristianHrs:gh-90871
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
ab8786a
gh-86802: Fix asyncio memory leak; shielded tasks where cancelled log…
ChristianHrsMay 20, 2025
b500a1f
Add blurb
ChristianHrsMay 20, 2025
37837ed
Fix formatting
ambvMay 20, 2025
0d595af
fix handle case with no exception
ChristianHrsMay 20, 2025
17d39e9
Fix offset with connection backlog - adapted the tests - created new …
ChristianHrsMay 20, 2025
d386169
Revert "Fix offset with connection backlog - adapted the tests - crea…
ChristianHrsMay 20, 2025
2c603b9
fix connection backlog offset - updated tests - added tests for 0 and 1
ChristianHrsMay 20, 2025
39f4654
Revert "fix connection backlog offset - updated tests - added tests f…
ChristianHrsMay 20, 2025
5893d43
Revert "gh-86802: Fix asyncio memory leak; shielded task exceptions l…
ChristianHrsMay 20, 2025
a78bde0
Fix connection backlog offset + updated tests + added test for backlo…
ChristianHrsMay 20, 2025
e871568
Merge branch 'gh-86802' into gh-90871
ChristianHrsMay 20, 2025
f710535
added blurb
ChristianHrsMay 20, 2025
0f28986
Update Misc/NEWS.d/next/Library/2025-05-20-21-45-58.gh-issue-90871.Gk…
kumaraditya303May 21, 2025
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
PrevPrevious commit
NextNext commit
Fix offset with connection backlog - adapted the tests - created new …
…tests for 0 and 1 connections
  • Loading branch information
@ChristianHrs
ChristianHrs committedMay 20, 2025
commit17d39e9a5f5a23e9df5eb58e4fff1a9eb55e955a
2 changes: 1 addition & 1 deletionLib/asyncio/selector_events.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -173,7 +173,7 @@ def _accept_connection(
# listening socket has triggered an EVENT_READ. There may be multiple
# connections waiting for an .accept() so it is called in a loop.
# See https://bugs.python.org/issue27906 for more details.
for _ in range(backlog):
for _ in range(backlog + 1):
try:
conn, addr = sock.accept()
if self._debug:
Expand Down
17 changes: 15 additions & 2 deletionsLib/test/test_asyncio/test_selector_events.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -347,6 +347,19 @@ def test_process_events_write_cancelled(self):
selectors.EVENT_WRITE)])
self.loop._remove_writer.assert_called_with(1)

def test_accept_connection_zero_one(self):
for backlog in [0, 1]:
sock = mock.Mock()
sock.accept.return_value = (mock.Mock(), mock.Mock())
with self.subTest(backlog):
mock_obj = mock.patch.object
with mock_obj(self.loop, '_accept_connection2') as accept2_mock:
self.loop._accept_connection(
mock.Mock(), sock, backlog=backlog)
self.loop.run_until_complete(asyncio.sleep(0))
print("Accepted vs Backlog:", sock.accept.call_count, backlog)
self.assertEqual(sock.accept.call_count, backlog + 1)

def test_accept_connection_multiple(self):
sock = mock.Mock()
sock.accept.return_value = (mock.Mock(), mock.Mock())
Expand All@@ -362,7 +375,7 @@ def test_accept_connection_multiple(self):
self.loop._accept_connection(
mock.Mock(), sock, backlog=backlog)
self.loop.run_until_complete(asyncio.sleep(0))
self.assertEqual(sock.accept.call_count, backlog)
self.assertEqual(sock.accept.call_count, backlog + 1)

def test_accept_connection_skip_connectionabortederror(self):
sock = mock.Mock()
Expand All@@ -388,7 +401,7 @@ def mock_sock_accept():
# as in test_accept_connection_multiple avoid task pending
# warnings by using asyncio.sleep(0)
self.loop.run_until_complete(asyncio.sleep(0))
self.assertEqual(sock.accept.call_count, backlog)
self.assertEqual(sock.accept.call_count, backlog + 1)

class SelectorTransportTests(test_utils.TestCase):

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp