MCPcopy
hub / github.com/benoitc/gunicorn / encode_message

Method encode_message

gunicorn/ctl/protocol.py:42–54  ·  view source on GitHub ↗

Encode a message for transmission. Args: data: Dictionary to encode Returns: Length-prefixed JSON bytes

(data: dict)

Source from the content-addressed store, hash-verified

40
41 @staticmethod
42 def encode_message(data: dict) -> bytes:
43 """
44 Encode a message for transmission.
45
46 Args:
47 data: Dictionary to encode
48
49 Returns:
50 Length-prefixed JSON bytes
51 """
52 payload = json.dumps(data).encode('utf-8')
53 length = struct.pack('>I', len(payload))
54 return length + payload
55
56 @staticmethod
57 def decode_message(data: bytes) -> dict:

Callers 6

write_messageMethod · 0.80
write_message_asyncMethod · 0.80
test_roundtripMethod · 0.80

Calls 1

encodeMethod · 0.80

Tested by 4

test_roundtripMethod · 0.64