Skip to content

Socket sendall for large buffers using memoryview#185

Merged
jeff5 merged 2 commits intojython:masterfrom
jeff5:sendall-fix
Jun 15, 2022
Merged

Socket sendall for large buffers using memoryview#185
jeff5 merged 2 commits intojython:masterfrom
jeff5:sendall-fix

Conversation

@jeff5
Copy link
Copy Markdown
Member

@jeff5 jeff5 commented Jun 12, 2022

This provides a _socket._realsocket.sendall that continues to send() until all the data has all gone. This fixes #60 (bjo 2618).

The PR follows the solution proposed by both Roland Walter and Gunter Bach (#80), but scope the lifetime of the memoryview using with.and There is also a test. We apply the fix also to ChildSocket.

There are FIXMEs in this code that lament our inability to use memoryview through its buffer interface, which results in a lot of data copying. A further change set is intended to correct that.

jeff5 added 2 commits June 11, 2022 17:31
This provides a _socket._realsocket.sendall that continues to send()
until all the data has all gone. This fixes jython#60 (bjo 2618).

We follow the solution proposed by both Roland Walter and Gunter Bach,
but scope the lifetime of the memoryview using with and there is a test.
We apply the fix also to ChildSocket.
We allow memoryview to be coerced to java.nio.ByteBuffer when presented
as a call argument, which in turn means it may be passed to networking
calls in the implementation of socket send(), for example. We are
careful to manage the life-cycle of memoryview slices.
@jeff5 jeff5 marked this pull request as ready for review June 12, 2022 13:44
@jeff5 jeff5 added this to the Jython 2.7.3 milestone Jun 13, 2022
@jeff5 jeff5 merged commit ec6dd91 into jython:master Jun 15, 2022
@jeff5 jeff5 deleted the sendall-fix branch June 15, 2022 09:35
@lins05 lins05 mentioned this pull request Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sendall of more than 64k not working

1 participant