MCPcopy Create free account
hub / github.com/F-Stack/f-stack / read_socket

Function read_socket

dpdk/usertools/dpdk-telemetry.py:26–38  ·  view source on GitHub ↗

Read data from socket and return it in JSON format

(sock, buf_len, echo=True, pretty=False)

Source from the content-addressed store, hash-verified

24
25
26def read_socket(sock, buf_len, echo=True, pretty=False):
27 """ Read data from socket and return it in JSON format """
28 reply = sock.recv(buf_len).decode()
29 try:
30 ret = json.loads(reply)
31 except json.JSONDecodeError:
32 print("Error in reply: ", reply)
33 sock.close()
34 raise
35 if echo:
36 indent = 2 if pretty else None
37 print(json.dumps(ret, indent=indent))
38 return ret
39
40
41def get_app_name(pid):

Callers 1

handle_socketFunction · 0.85

Calls 3

recvMethod · 0.80
printFunction · 0.50
closeMethod · 0.45

Tested by

no test coverage detected