Created
April 26, 2012 13:40
-
-
Save laiyonghao/2499696 to your computer and use it in GitHub Desktop.
abu.rpc request encode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import struct | |
import abu.rpc.rpc_pb2 as rpc | |
import echo_pb2 as echo | |
PYLOAD = 'hello' * 30 | |
def new(): | |
arg = echo.Packet(text = PYLOAD) | |
req = rpc.Request() | |
req.method = 'echo' | |
req.request = arg.SerializeToString() | |
pkt = rpc.Packet() | |
pkt.type = rpc.REQUEST | |
pkt.identify = 100 | |
pkt.serialized = req.SerializeToString() | |
buff = pkt.SerializeToString() | |
packed_buff_len = struct.pack('!I', len(buff)) | |
return packed_buff_len + buff | |
for i in xrange(10000): | |
new() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment