MCPcopy Create free account
hub / github.com/ActiveState/code / recvall

Function recvall

recipes/Python/577569_NBD_server_in_python/recipe-577569.py:5–10  ·  view source on GitHub ↗
(sock, length)

Source from the content-addressed store, hash-verified

3# Working: nbd protocol, read/write serving up files, error handling, file size detection, in theory, large file support... not really, so_reuseaddr, nonforking
4
5def recvall(sock, length):
6 rv = []
7 while sum(map(len, rv)) < length:
8 rv.append(sock.recv(length-sum(map(len, rv))))
9 assert rv[-1], "no more data to read"
10 return ''.join(rv)
11
12def serveclient():
13 READ, WRITE, CLOSE = 0,1,2

Callers 1

serveclientFunction · 0.70

Calls 5

mapFunction · 0.85
sumFunction · 0.50
appendMethod · 0.45
recvMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected