MCPcopy Index your code
hub / github.com/python/cpython / recv_bytes_into

Method recv_bytes_into

Lib/multiprocessing/connection.py:228–251  ·  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

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

Callers 1

test_connectionMethod · 0.80

Calls 8

_check_closedMethod · 0.95
_check_readableMethod · 0.95
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