MCPcopy Index your code
hub / github.com/RustPython/RustPython / recv_bytes_into

Method recv_bytes_into

Lib/multiprocessing/connection.py:221–244  ·  view source on GitHub ↗

Receive bytes data into a writeable bytes-like object. Return the number of bytes read.

(self, buf, offset=0)

Source from the content-addressed store, hash-verified

219 return buf.getvalue()
220
221 def recv_bytes_into(self, buf, offset=0):
222 """
223 Receive bytes data into a writeable bytes-like object.
224 Return the number of bytes read.
225 """
226 self._check_closed()
227 self._check_readable()
228 with memoryview(buf) as m:
229 # Get bytesize of arbitrary buffer
230 itemsize = m.itemsize
231 bytesize = itemsize * len(m)
232 if offset < 0:
233 raise ValueError("negative offset")
234 elif offset > bytesize:
235 raise ValueError("offset too large")
236 result = self._recv_bytes()
237 size = result.tell()
238 if bytesize < offset + size:
239 raise BufferTooShort(result.getvalue())
240 # Message can fit in dest
241 result.seek(0)
242 result.readinto(m[offset // itemsize :
243 (offset + size) // itemsize])
244 return size
245
246 def recv(self):
247 """Receive a (picklable) object"""

Callers 1

test_connectionMethod · 0.80

Calls 9

_check_closedMethod · 0.95
_check_readableMethod · 0.95
lenFunction · 0.85
BufferTooShortClass · 0.85
_recv_bytesMethod · 0.45
tellMethod · 0.45
getvalueMethod · 0.45
seekMethod · 0.45
readintoMethod · 0.45

Tested by 1

test_connectionMethod · 0.64