8000 GH-91166: zero copy SelectorSocketTransport transport implementation by kumaraditya303 · Pull Request #31871 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-91166: zero copy SelectorSocketTransport transport implementation #31871

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

Merged
merged 23 commits into from
Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
kumaraditya303 committed Nov 28, 2022
commit e1e43621d4e7c4c483cb62b9f5cd82b6ee4d010d
5 changes: 3 additions & 2 deletions Lib/asyncio/selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ def _write_sendmsg(self):
elif self._eof:
self._sock.shutdown(socket.SHUT_WR)

def _adjust_leftover_buffer(self, nbytes: int, /) -> None:
def _adjust_leftover_buffer(self, nbytes: int) -> None:
buffer = self._buffer
while nbytes:
b = buffer.popleft()
Expand All @@ -1127,7 +1127,8 @@ def _write_send(self):
if self._conn_lost:
return
try:
buffer = self._buffer.popleft()
buffer = bytearray().join(self._buffer)
self._buffer.clear()
n = self._sock.send(buffer)
if n != len(buffer):
# Not all data was written
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_asyncio/test_selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def test_write_sendmsg_no_data(self):
self.assertFalse(self.sock.sendmsg.called)
self.assertEqual(list_to_buffer([b'data']), transport._buffer)

@unittest.skipUnless(selector_events.HAVE_SENDMSG, 'no sendmsg')
@unittest.skipUnless(selector_events._HAS_SENDMSG, 'no sendmsg')
def test_write_sendmsg_full(self):
data = memoryview(b'data')
self.sock.sendmsg = mock.Mock()
Expand All @@ -760,7 +760,7 @@ def test_write_sendmsg_full(self):
self.assertTrue(self.sock.sendmsg.called)
self.assertFalse(self.loop.writers)

@unittest.skipUnless(selector_events.HAVE_SENDMSG, 'no sendmsg')
@unittest.skipUnless(selector_events._HAS_SENDMSG, 'no sendmsg')
def test_write_sendmsg_partial(self):

data = memoryview(b'data')
Expand Down
0